Docker CLI Commands Cheatsheet
July 10, 2025
The commands I reach for most. All lowercase docker, and long flags use --.
Images
docker pull imageName:tagName # download an image
docker images # list all images
docker rmi imageName # remove an image
docker build -t app:tagName ./dir # build an image from a Dockerfile in ./dir
Containers
docker ps # running containers
docker ps -a # all containers (incl. stopped)
docker ps -a | grep someName # search containers by name
# start a new container
docker run --name myContainer -d -p hostPort:containerPort \
--network networkName imageName:tag
docker stop containerId # stop a container
docker start containerId # resume a stopped container
docker rm containerId # remove a container
Flags used with docker run:
--name— name for the container-d— detached (run in the background)-p hostPort:containerPort— publish a port (HOST:CONTAINER)--network— attach to a named network
Logs
docker logs containerId | tail # show the last part of the logs
docker logs containerId -f # stream (follow) the logs live
Networks
docker network create networkName # create a network
docker network ls # list all networks
Containers on the same network reach each other by container/service name. See also [[docker-compose]] and [[dockerfile-instructions]].