Build ⤢ docker buildBuild an image from a Dockerfile. docker build -t app:1.0 . ⤢ docker build --no-cacheBuild the image again from scratch, ignoring cached layers. docker build --no-cache -t app:1.0 . ⤢ docker build --targetBuild only up to a named stage in a multi-stage Dockerfile. docker build --target deps -t app:deps . ⤢ docker buildxBuild images through the buildx plugin, which drives BuildKit. docker buildx build -t app:1.0 . ⤢ docker buildx build --platformBuild one image for several CPU architectures. docker buildx build --platform linux/amd64,linux/arm64 -t app:1.0 --push . Images ⤢ docker pullDownload an image from a registry. docker pull node:20 ⤢ docker imagesList images stored locally. docker images ⤢ docker tagCreate a new tag that points at the same image. docker tag app:1.0 app:latest ⤢ docker rmiRemove one or more local images. docker rmi app:1.0 Container lifecycle ⤢ docker runCreate and start a container from an image. docker run -p 8080:3000 app ⤢ docker createCreate a container without starting it. docker create --name web app ⤢ docker startStart a container that was stopped. docker start web ⤢ docker stopStop a running container gracefully. docker stop web ⤢ docker restartStop and start a container in one step. docker restart web ⤢ docker killForce-stop a container without waiting for a graceful shutdown. docker kill web ⤢ docker pauseFreeze all processes inside a container. docker pause web ⤢ docker unpauseUnfreeze the processes of a paused container. docker unpause web ⤢ docker waitBlock until a container stops, then print its exit code. docker wait web ⤢ docker psList running containers; add -a to include stopped ones. docker ps -a ⤢ docker renameGive an existing container a new name. docker rename web web-old ⤢ docker updateChange resource limits or the restart policy of a container. docker update --restart=unless-stopped web ⤢ docker rmRemove a stopped container. docker rm web Run flags ⤢ docker run -dRun the container in the background and print its ID. docker run -d -p 8080:80 app ⤢ docker run -pPublish a container port on a host port. docker run -p 8080:80 app ⤢ docker run -vMount a host folder or a named volume into the container. docker run -v app-data:/data app ⤢ docker run -eSet an environment variable in the container. docker run -e MODE=prod app ⤢ docker run --nameGive the container a fixed name to use in later commands. docker run --name web app ⤢ docker run --rmDelete the container when it exits. docker run --rm app ⤢ docker run --networkStart the container on a specific network. docker run --network net app ⤢ docker run --restartTell Docker when to restart the container. docker run --restart unless-stopped app ⤢ docker run -itAllocate a terminal and keep stdin open for an interactive session. docker run -it alpine sh ⤢ docker run --entrypointReplace the image's entrypoint with your own command. docker run --entrypoint sh app ⤢ docker run --memory / --cpusCap the memory or CPU share the container can use. docker run --memory 512m --cpus 0.5 app Inspecting ⤢ docker logsRead a container's stdout and stderr; -f follows new output as it arrives. docker logs -f web ⤢ docker inspectShow low-level config and state of a container or image. docker inspect web ⤢ docker inspect --formatPull one field out of inspect with a Go template. docker inspect --format '{{.State.Status}}' web ⤢ docker portList the host ports a container publishes. docker port web ⤢ docker diffShow files a container changed compared to its image. docker diff web ⤢ docker statsLive CPU, memory, and network for running containers. docker stats ⤢ docker topList the processes running inside a container. docker top web ⤢ docker eventsStream Docker events from the daemon as they happen. docker events --filter type=container ⤢ docker system dfShow disk space used by images, containers, volumes, and cache. docker system df ⤢ docker infoShow system-wide Docker settings and state. docker info Exec & attach ⤢ docker execRun a command inside a running container. docker exec -it web sh ⤢ docker attachAttach your terminal to a container's main process. docker attach web Files & registry ⤢ docker cpCopy files between a container and the local filesystem. docker cp web:/app/logs ./logs ⤢ docker loginSign in to a registry from the CLI. docker login ⤢ docker logoutSign out of a registry. docker logout ⤢ docker pushUpload a local image to a registry. docker push user/app:1.0 ⤢ docker saveWrite an image to a tar file. docker save -o app.tar app:1.0 ⤢ docker loadRead an image from a tar file. docker load -i app.tar ⤢ docker exportWrite a container's filesystem to a tar file. docker export web > web.tar ⤢ docker importCreate an image from a tar filesystem. docker import web.tar web:snap ⤢ docker commitTurn a container's current state into a new image. docker commit web app:snap Volumes ⤢ docker volume createCreate a named volume for persistent data. docker volume create data ⤢ docker volume lsList volumes. docker volume ls ⤢ docker volume rmRemove a volume. docker volume rm data Networks ⤢ docker network lsList networks. docker network ls ⤢ docker network createCreate a network so containers can reach each other. docker network create net ⤢ docker network connectConnect a running container to a network. docker network connect net web Compose ⤢ docker compose upBuild, (re)create, and start the services in compose.yaml; -d leaves them running in the background. docker compose up -d ⤢ docker compose up --buildStart the services and rebuild their images first. docker compose up --build -d ⤢ docker compose execRun a command inside a running service container. docker compose exec api sh ⤢ docker compose logsTail logs for one or more services. docker compose logs -f api ⤢ docker compose psList the service containers Compose manages. docker compose ps ⤢ docker compose stopStop the service containers without removing them. docker compose stop ⤢ docker compose restartRestart the service containers. docker compose restart api ⤢ docker compose downStop and remove containers and networks; -v also removes named volumes. docker compose down ⤢ docker compose configShow the final Compose config after merges and env substitution. docker compose config Cleanup ⤢ docker system pruneRemove stopped containers, dangling images, and unused networks; -a --volumes also removes unused images and volumes. docker system prune -af ⤢ docker container pruneRemove all stopped containers. docker container prune ⤢ docker image pruneRemove unused or dangling images. docker image prune -a ⤢ docker volume pruneRemove volumes no container uses. docker volume prune ⤢ docker network pruneRemove networks no container uses. docker network prune ⤢ docker builder pruneRemove the cached build layers. docker builder prune