The essential Docker commands, from building images to orchestrating with Compose.
| docker build -t name:tag . | Build an image from a Dockerfile in the current directory |
| docker images | List all local images |
| docker pull image:tag | Pull an image from a registry |
| docker push image:tag | Push an image to a registry |
| docker rmi image | Remove a local image |
| docker tag source target:tag | Tag an image with a new name |
| docker image prune | Remove dangling (untagged) images |
| docker image prune -a | Remove all unused images, not just dangling ones |
| docker history image | Show the layer history of an image |
| docker inspect image | Display detailed image metadata as JSON |
| docker run image | Create and start a container from an image |
| docker run -d image | Run a container in detached (background) mode |
| docker run -it image sh | Run interactively with a shell |
| docker run --name name image | Run a container with a custom name |
| docker run -p host:container image | Map a host port to a container port |
| docker run -v host:container image | Bind-mount a host directory into the container |
| docker run --rm image | Automatically remove the container when it exits |
| docker run -e KEY=VAL image | Set an environment variable |
| docker ps | List running containers |
| docker ps -a | List all containers including stopped |
| docker stop container | Gracefully stop a running container |
| docker kill container | Force-stop a container immediately |
| docker start container | Start a stopped container |
| docker restart container | Restart a container |
| docker rm container | Remove a stopped container |
| docker rm -f container | Force-remove a container, even if running |
| docker container prune | Remove all stopped containers |
| docker exec -it container sh | Open an interactive shell inside a running container |
| docker exec container command | Run a one-off command in a running container |
| docker logs container | View container logs |
| docker logs -f container | Follow (tail) container logs in real time |
| docker logs --tail n container | Show only the last n lines of logs |
| docker logs --since time container | Show logs since a timestamp or duration (e.g. 10m) |
| docker top container | Display running processes inside a container |
| docker stats | Live stream of resource usage for all running containers |
| docker inspect container | Detailed container metadata as JSON |
| docker cp container:path local | Copy files from a container to the host |
| docker cp local container:path | Copy files from the host into a container |
| docker volume create name | Create a named volume |
| docker volume ls | List all volumes |
| docker volume inspect name | Show volume details |
| docker volume rm name | Remove a volume |
| docker volume prune | Remove all unused volumes |
| docker run -v vol:path image | Mount a named volume into a container |
| docker run --mount type=bind,src=host,dst=container image | Bind mount using the --mount syntax (more explicit) |
| docker network create name | Create a user-defined bridge network |
| docker network ls | List all networks |
| docker network inspect name | Show network details and connected containers |
| docker network connect net container | Attach a running container to a network |
| docker network disconnect net container | Detach a container from a network |
| docker network rm name | Remove a network |
| docker network prune | Remove all unused networks |
| docker run --network name image | Run a container on a specific network |
| docker compose up | Create and start all services defined in compose.yaml |
| docker compose up -d | Start services in detached mode |
| docker compose up --build | Rebuild images before starting services |
| docker compose down | Stop and remove containers, networks |
| docker compose down -v | Also remove named volumes declared in the file |
| docker compose ps | List containers managed by Compose |
| docker compose logs -f | Follow logs from all services |
| docker compose logs service | View logs for a specific service |
| docker compose exec service sh | Open a shell in a running service container |
| docker compose run service cmd | Run a one-off command against a service |
| docker compose pull | Pull the latest images for all services |
| docker compose build | Build or rebuild all service images |
| docker compose config | Validate and display the resolved compose file |
| docker system df | Show disk usage by images, containers, and volumes |
| docker system prune | Remove stopped containers, unused networks, dangling images |
| docker system prune -a --volumes | Nuclear option — remove everything unused including volumes |
| docker info | Display system-wide Docker information |
| docker version | Show Docker client and server versions |
| FROM image:tag | Base image for the build |
| WORKDIR /app | Set the working directory for subsequent instructions |
| COPY src dest | Copy files from host into the image |
| RUN command | Execute a command during the build (creates a new layer) |
| ENV KEY=VAL | Set an environment variable |
| ARG name=default | Define a build-time variable |
| EXPOSE port | Document which port the container listens on |
| VOLUME /data | Create a mount point for a volume |
| CMD ["exec", "arg"] | Default command when the container starts (overridable) |
| ENTRYPOINT ["exec"] | Main executable — CMD becomes default arguments |
| HEALTHCHECK CMD command | Define a command to check if the container is healthy |
| USER name | Switch to a non-root user for subsequent instructions |
| .dockerignore | File listing patterns to exclude from the build context |
No commands match your search.