Docker Cheatsheet


This is a quick cheat-sheet for the most commonly used Docker Commands.

List Docker CLI commands

docker container --help

Display Docker version and info

docker --version
docker version
docker info

Excecute Docker image

docker run hello-world

List Docker images

docker image ls

List Docker containers (running, all, all in quiet mode)

docker container ls
docker container ls -all
docker container ls -a -q

Start docker daemon

docker -d

Start a container with an interactive shell

docker run -ti <image_name> /bin/bash

“shell” into a running container (docker-1.3+)

docker exec -ti <container_name> bash

inspect a running container

docker inspect <container_name> (or <container_id>)

Get the process ID for a container

docker inspect --format {{.State.Pid}} <container_name_or_ID>

List the current mounted volumes for a container (and pretty print)

docker inspect --format='{{json .Volumes}}' <container_id> | python -mjson.tool

Copy files/folders between a container and your host

docker cp foo.txt mycontainer:/foo.txt

List currently running containers

docker ps

List all containers

docker ps -a

List all images

docker images

To dive deeper down this rabbit hole: Docker Cheat Sheet. This is a great and very thorough reference.