Skip to content

Instantly share code, notes, and snippets.

@psiborg
Last active December 7, 2020 19:45
Show Gist options
  • Save psiborg/fc046a9a38deb4f8dd969a17c72495ea to your computer and use it in GitHub Desktop.
Save psiborg/fc046a9a38deb4f8dd969a17c72495ea to your computer and use it in GitHub Desktop.
Docker commands #docker #geospatial

Basics

docker version
docker info

docker login
docker logout

docker image ls
docker container ls --all

docker network ls
docker ps
docker ps -a

# Remove exited containers
docker rm $(docker ps -a -f status=exited -q)

# Remove dangling images
docker rmi $(docker images -f "dangling=true" -q)

# Remove dangling volumes
docker volume rm $(docker volume ls -f dangling=true -q)

docker run hello-world

Alpine

docker pull alpine
docker run alpine ifconfig
docker run -it alpine /bin/sh

(Press Ctrl-P Ctrl-Q to detach from the container without stopping)

Ubuntu

docker pull ubuntu
docker run -it ubuntu bash

Earth at Night: Flat Maps [https://earthobservatory.nasa.gov/features/NightLights]

13500x6750 (3km) GeoTIFF 64.4 MB [https://www.nasa.gov/specials/blackmarble/2016/globalmaps/georeferrenced/BlackMarble_2016_3km_geo.tif]

docker run -v $(pwd):/data geodata/gdal gdal_translate -of Gtiff -a_ullr LeftLon UpperLat RightLon BottomLat -a_srs EPSG:4326 BlackMarble_2016_3km_geo.tif BlackMarble_2016_3km_geo_4326.tif

docker run -v $(pwd):/data geodata/gdal gdalwarp -s_srs EPSG:4326 -t_srs EPSG:3857 BlackMarble_2016_3km_geo_4326.tif BlackMarble_2016_3km_geo_3857.tif

docker run -v $(pwd):/data geodata/gdal gdal2tiles.py --profile=mercator --z=1-8 --webviewer=leaflet --verbose BlackMarble_2016_3km_geo_3857.tif tiles

GDAL [https://www.gdal.org/gdal_utilities.html]

docker pull geodata/gdal
docker run -ti geodata/gdal /bin/bash
docker run -v $(pwd):/data geodata/gdal gdalinfo odm_orthophoto.tif
docker run -v $(pwd):/data geodata/gdal gdal2tiles.py --profile=mercator --z=1-20 --webviewer=leaflet --verbose odm_orthophoto.tif tiles
#Requires -RunAsAdministrator
# Get the Hyper-V feature and store it in $hyperv
$hyperv = Get-WindowsOptionalFeature -FeatureName Microsoft-Hyper-V-All -Online
# Check if Hyper-V is enabled
if($hyperv.State -eq "Enabled") {
Write-Host "Hyper-V is enabled."
} else {
Write-Host "Hyper-V is disabled."
}

OpenDroneMap [https://www.opendronemap.org/]

docker pull opendronemap/opendronemap

If you have Docker installed, place your JPGs in a folder named "images" (e.g., /Users/{username}/Projects/bv/images) then run:

Mac/Linux

cd ~/Projects/bv/
docker run -ti --rm -v $(pwd)/images:/code/images -v $(pwd)/odm_orthophoto:/code/odm_orthophoto -v $(pwd)/odm_texturing:/code/odm_texturing opendronemap/opendronemap

Increase Docker's memory allocation from default 2GB to 16GB if you get this error:

Killed
Traceback (most recent call last):
  File "/code/run.py", line 47, in <module>
    plasm.execute(niter=1)
  File "/code/scripts/smvs.py", line 85, in process
    system.run('%s %s %s' % (context.smvs_path, ' '.join(config), tree.smvs))
  File "/code/opendm/system.py", line 34, in run
    raise Exception("Child returned {}".format(retcode))
Exception: Child returned 137

Or try:

docker run -ti --rm -v $(pwd)/images:/code/images -v $(pwd)/odm_orthophoto:/code/odm_orthophoto -v $(pwd)/odm_texturing:/code/odm_texturing opendronemap/opendronemap --use-opensfm-dense
docker run -it --rm
-v "$(pwd)/images:/code/images"
-v "$(pwd)/odm_georeferencing:/code/odm_georeferencing"
-v "$(pwd)/odm_meshing:/code/odm_meshing"
-v "$(pwd)/odm_orthophoto:/code/odm_orthophoto"
-v "$(pwd)/odm_texturing:/code/odm_texturing"
-v "$(pwd)/odm_dem:/code/odm_dem"
-v "$(pwd)/opensfm:/code/opensfm"
-v "$(pwd)/smvs:/code/smvs" 
opendronemap/opendronemap
--use-opensfm-dense
--rerun odm_dem
--dsm

SQL Server with Docker

https://hub.docker.com/_/microsoft-mssql-server

https://docs.microsoft.com/en-us/sql/linux/quickstart-install-connect-docker?view=sql-server-2017&pivots=cs1-bash

https://docs.microsoft.com/en-us/sql/linux/quickstart-install-connect-docker?view=sql-server-ver15&pivots=cs1-bash

sudo docker pull mcr.microsoft.com/mssql/server:2017-latest

sudo docker run -e 'ACCEPT_EULA=Y' -e 'SA_PASSWORD=<YourStrong!Passw0rd>' -p 1433:1433 --name sql1 -d mcr.microsoft.com/mssql/server:2017-latest

sudo docker ps -a

CONTAINER ID        IMAGE                                        COMMAND                  CREATED             STATUS                   PORTS                    NAMES
fe3ed76d8ac9        mcr.microsoft.com/mssql/server:2017-latest   "/opt/mssql/bin/sqls…"   14 seconds ago      Up 13 seconds            0.0.0.0:1433->1433/tcp   sql1

docker logs fe3ed76d8ac9

sudo docker exec -it sql1 "bash"

	/opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P '<YourStrong!Passw0rd>'

	SELECT Name from sys.Databases
	GO
	QUIT

	exit

docker images
docker rmi <IMAGE ID>

docker ps -a
docker rm <CONTAINER ID>

docker stop $(docker ps -a -q)
docker rm $(docker ps -a -q)

Tensorflow

docker pull tensorflow/tensorflow
docker run -it -p 8888:8888 tensorflow/tensorflow   # Start a Jupyter notebook server as root
docker run -u $(id -u):$(id -g) -it -p 8888:8888 tensorflow/tensorflow  # as your userid
$ git clone https://apps-munichre.visualstudio.com/DefaultCollection/Excite%20Sandbox/_git/Xui.Demo
$ cd Xui.Demo

$ docker-compose up -d
$ docker ps
$ docker exec -it <container_id> bash
root@<container_id>:/var/www/html# apt update
root@<container_id>:/var/www/html# apt-get install git

root@<container_id>:/var/www/html# composer update
root@<container_id>:/var/www/html# composer run build

http://localhost:9000/

$ docker-compose down -v

$ docker image ls
$ docker image rm <image_id>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment