Cheetsheet of Docker images and commands that I frequently use. Not comprehensive!

If you need to install and configure Docker first, check out QubesOS: Automatically Install and Configure Docker-CE in Debian.

Table of Contents

Command: docker pull

Pull in useful images.

user@d9-dvm:~$
1
2
3
4
5
6
7
docker pull lgsd/diamond
> Using default tag: latest
> latest: Pulling from lgsd/diamond
> a3ed95caeb02: Pull complete 
> c813975513b8: Pull complete 
> Digest: sha256:ca7dc57b0b99ef770fb189d4719d37627b44757d526a47fe1d55ce3c2ab23c68
> Status: Downloaded newer image for lgsd/diamond:latest

Command: docker images

List downloaded images.

user@d9-dvm:~$
1
2
3
4
5
docker images
> REPOSITORY                  TAG                 IMAGE ID            CREATED             > SIZE
> jguyomard/hugo-builder      latest              547b5190dd83        3 days ago          > 47.9MB
> mikebirdgeneau/jupyterlab   latest              3e5323a0e130        2 months ago        > 1.03GB
> lgsd/diamond                latest              cf1d0274f4be        2 years ago         > 1.21MB

Command: docker run -it

Run an interactive command in an image.

Example: Run the sh shell using the ‘lgsd/diamond’ image in an interactive container with pseudo-TTY (-i|–interactive; -t|–tty=false); -it also works.

user@d9-dvm:~$
1
2
3
4
docker run -i -t lgsd/diamond sh
> / # echo "hello world!"
> hello world!
> / # exit

Command: docker run -d

Run the container in detatched mode (-d|–detach)

user@d9-dvm:~$
1
2
docker run -d -p 1313:1313 -t lgsd/docker-hugo
> 322d2b4c0ca128fd0f2f9a28b61878b9c0f8cdf36b2bdc5e93df28ce95f8aeef

Command: docker ps

List running containers.

user@d9-dvm:~$
1
2
3
docker ps
> CONTAINER ID        IMAGE                       COMMAND                  CREATED             STATUS              PORTS                              NAMES
> 322d2b4c0ca1        lgsd/docker-hugo            "/bin/hugo server -w…"   15 seconds ago      Up 14 seconds       1313/tcp, 0.0.0.0:1318->1318/tcp   epic_bardeen

Command: docker stop

Stop a running container.

user@d9-dvm:~$
1
2
docker stop 322d2b4c0ca1
> 322d2b4c0ca1

Command: docker rm

Kill a specified container process using its container ID. Containers need to be stopped before removing them. Alternatively, use with the --force flag.

user@d9-dvm:~$
1
2
docker rm 322d2b4c0ca1
> 322d2b4c0ca1

Kill all running container processes.

user@d9-dvm:~$
1
2
3
docker rm $(docker ps -aq)
> b78243a30404
> 3c9f5a1104af

Applications

JupyterLab

docker run -it --rm -p 8888:8888 -v $(pwd):/opt/app/data mikebirdgeneau/jupyterlab

Hugo

Run a local server for build previews. (Should be run in the top-level folder of the Hugo source site.) Can also add the -D flag to also include draft pages and posts in the build output.

user@d9-dvm:~$
1
docker run --rm -it -v $(pwd):/src -p 1313:1313 -u hugo jguyomard/hugo-builder hugo server -D --bind 0.0.0.0'

New post/page

user@d9-dvm:~$
1
2
3
4
5
# foo.md under the ./content/post directory.
docker run --rm -it -v $(pwd):/src -u hugo jguyomard/hugo-builder hugo new post/foo.md

# bar.md under the ./content/page directory.
docker run --rm -it -v $(pwd):/src -u hugo jguyomard/hugo-builder hugo new page/bar.md

Build site

user@d9-dvm:~$
1
docker run --rm -it -v $(pwd):/src -u hugo jguyomard/hugo-builder hugo

Useful Images

References