Docker notes

Posted by John Liu on Friday, June 16, 2023

Get help

docker --help

List all existing containers

(without truncating result string)

docker ps -a --no-trunc

Start a container

(containner name is case sensitive)

docker start <container name>

Show current downloaded images

docker images

To download an image from a registry

(use :latest or :1.2.3 tag for specific version)

docker pull <docker_image>:latest

To create and run a containner

(use create instead of run to just create a containner)

docker run -it --name DataApiBuilder -v "c:\DataAPIBuilder\Samples:/App/Samples" -p 5004:5000 mcr.microsoft.com/azure-databases/data-api-builder --ConfigFileName ./Samples/dab-config.json --add-host host.docker.internal:host-gateway

Assumptions in the above command: you are run the command under C:\DataAPIBuilder folder, and there is a Samples subfolder containing the dab-config.json DataApiBuilder configuration file. With the –add-host, the container will then be able to communicate with externa resources via IP, such as connect to SQL database on the host server.

To upgrade a container to the new version

First download the image. Then remove the old container (if want to reuse the same container name. Remember to record any specific settings using docker ps -a –no-trunc). Recreate a new container with the newly downloaded image.

docker pull <docker_image>:latest
docker rm <container id>
docker create/run ...

Other references

Docker Advice for SQL Server in Production