Loading...
Loading...
The Docker commands you use weekly, grouped by what you're trying to do build, run, exec, network, prune.
Build and manage images.
docker build -t myapp .Build an image from the Dockerfile in current dir.docker build --target dev -t myapp:dev .Build a specific multi-stage target.docker imagesList local images.docker rmi myappRemove an image.docker pull node:22-alpinePull an image from a registry.docker push myorg/myapp:v1Push an image to a registry.docker tag myapp myorg/myapp:v1Tag an image for pushing.Run and inspect containers.
docker run -d -p 8080:80 nginxRun nginx in background, map port 80 8080.docker run -it --rm node:22 shInteractive shell, removed on exit.docker psList running containers.docker ps -aList all containers, including stopped.docker stop <id>Gracefully stop a container.docker rm <id>Remove a stopped container.docker logs -f <id>Follow container logs.docker exec -it <id> shOpen a shell inside a running container.Persistent data and inter-container comms.
docker volume create mydataCreate a named volume.docker volume lsList volumes.docker run -v mydata:/data myappMount a volume into a container.docker run -v $(pwd):/app myappBind-mount current dir for live reload.docker network lsList networks.docker network create mynetCreate a user-defined bridge network.Multi-container apps.
docker compose up -dStart the stack in background.docker compose downStop and remove all stack containers.docker compose logs -f webFollow logs for one service.docker compose exec web shOpen a shell in a service container.docker compose build --no-cacheRebuild images from scratch.Reclaim disk space.
docker system dfShow disk usage by Docker.docker system pruneRemove stopped containers, dangling images, unused networks.docker system prune -a --volumesRemove EVERYTHING unused, including volumes. Be sure.docker image pruneRemove dangling images only.We turn AI cheatsheets into production code. Tell us what you're building.