xutil.dev
Login

Docker Cheatsheet

Quick reference for Docker commands covering container lifecycle, image management, networking, volumes, Docker Compose, inspect, and registry operations

68 commands

docker run

Create and start a new container

docker run -it

Run container in interactive mode

docker run --rm

Run container that auto-removes on exit

docker run -v

Run container with volume mount

docker run -e

Run container with environment variables

docker run --name

Run container with a specific name

docker run --network

Run container on a specific network

docker start

Start a stopped container

docker stop

Stop a running container

docker restart

Restart a container

docker rm

Remove a container

docker rm -f

Force remove a running container

docker build

Build an image from a Dockerfile

docker build --no-cache

Build image without cache

docker build -f

Build with a specific Dockerfile

docker images

List local images

docker rmi

Remove an image

docker tag

Tag an image

docker history

Show image layer history

docker image prune

Remove unused images

docker save

Save image to tar archive

docker load

Load image from tar archive

docker network ls

List networks

docker network create

Create a new network

docker network create --driver

Create network with specific driver

docker network connect

Connect container to network

docker network disconnect

Disconnect container from network

docker network inspect

Inspect network details

docker network rm

Remove a network

docker network prune

Remove unused networks

docker volume ls

List volumes

docker volume create

Create a new volume

docker volume inspect

Inspect volume details

docker volume rm

Remove a volume

docker volume prune

Remove unused volumes

docker run --mount

Run container with mount options

docker run --tmpfs

Run container with tmpfs mount

docker cp

Copy files between container and host

docker compose up

Start Compose services

docker compose down

Stop and remove Compose services

docker compose down -v

Stop Compose and remove volumes

docker compose build

Build Compose service images

docker compose ps

List Compose service status

docker compose logs

View Compose service logs

docker compose exec

Execute command in Compose service

docker compose pull

Pull Compose service images

docker compose restart

Restart Compose services

docker compose config

Validate and view Compose config

docker ps

List running containers

docker ps -a

List all containers including stopped

docker logs

View container logs

docker logs --tail

View last N lines of container logs

docker exec

Execute command in running container

docker inspect

Display detailed container/image info

docker stats

Display real-time container resource usage

docker top

Display processes in a container

docker diff

Show container filesystem changes

docker events

Display real-time Docker daemon events

docker system df

Show Docker disk usage

docker system prune

Remove all unused resources

docker pull

Pull image from registry

docker push

Push image to registry

docker login

Log in to Docker registry

docker logout

Log out from Docker registry

docker search

Search images on Docker Hub

docker manifest inspect

Inspect image manifest

docker pull --platform

Pull image for specific platform

docker buildx build --push

Multi-platform build and push