System Commands


Command Description
docker version Show Docker version information
docker system info Display system-wide information
docker system df Show Docker disk usage
docker system prune Remove unused containers, networks, and dangling images

Basic Commands


Command Description
docker run Run a container
docker container ls or docker ps List running containers
docker container ls -a or docker ps -a List all containers (including stopped)
docker stop CONTAINER_NAME Stop a container
docker rm CONTAINER_NAME Remove a container
docker pull IMAGE[:TAG] Pull an image from registry
docker images List local images on Docker Host
docker build -t IMAGE_NAME[:TAG] . Build an image from Dockerfile

Common Options


Option Description
-d Run container in background (detached mode)
-p HOST_PORT:CONTAINER_PORT Map container port to host port (expose container to outside)
-v HOST_PATH:CONTAINER_PATH Mount a volume
--name CONTAINER_NAME Assign a name to container
-e KEY=VALUE Set environment variables
--network NETWORK Connect to a network
--restart=always Always restart container
-it Interactive with TTY (combines -i and -t)
--rm Remove container when it exits
--memory="512m" Memory limit
--cpus="0.5" CPU limit
--user USER Username or UID
--workdir DIR Working directory in container
--entrypoint CMD Override the default entrypoint

Container Lifecycle


Command Description
docker start CONTAINER_NAME Start a stopped container
docker restart CONTAINER_NAME Restart a container
docker pause CONTAINER_NAME Pause a container
docker unpause CONTAINER_NAME Unpause a container
docker logs CONTAINER_NAME Get container logs
docker logs -f CONTAINER_NAME Follow container logs
docker stats Display live container resource usage
docker inspect CONTAINER_NAME Show detailed container information
docker exec -it CONTAINER_NAME /bin/sh Get a shell inside the container
docker exec -it CONTAINER_NAME COMMAND Execute command in running container
docker top CONTAINER_NAME Display running processes in a container
docker container prune Remove all stopped containers
docker rename OLD_NAME NEW_NAME Rename a container
docker kill CONTAINER_NAME Send SIGKILL to a container

Images and Volumes


Command Description
docker image ls List images
docker image history IMAGE Show image history
docker save IMAGE > file.tar Save image to a tar archive
docker load < file.tar Load image from a tar archive
docker tag SOURCE_IMAGE TARGET_IMAGE Create a tag for an image
docker commit CONTAINER IMAGE_NAME Create image from a container
docker rmi IMAGE Remove an image
docker image prune Remove dangling images
docker volume create VOLUME_NAME Create a volume
docker volume ls List volumes
docker volume inspect VOLUME_NAME Display detailed volume information
docker volume rm VOLUME_NAME Remove a volume
docker volume prune Remove unused volumes

Network


Command Description
docker network create NETWORK_NAME Create a network
docker network ls List networks
docker network inspect NETWORK Display detailed network information
docker network connect NETWORK CONTAINER_NAME Connect container to network
docker network disconnect NETWORK CONTAINER_NAME Disconnect container from network
docker network prune Remove all unused networks

Troubleshooting and Debugging


Command Description
docker logs CONTAINER View logs from a container
docker inspect CONTAINER Show detailed config and metadata
docker events Monitor real-time Docker events
docker stats Show live resource usage
journalctl -u docker.service View Docker daemon logs (Linux with systemd)

Docker Compose


Command Description
docker compose config Validate and view the compose file
docker compose up Start services defined in compose.yaml
docker compose up -d Start services in detached mode
docker compose up -d --scale SERVICE=NUM Scale a service
docker compose logs View logs
docker compose logs -f Follow logs
docker compose ps List containers
docker compose exec SERVICE COMMAND Execute command in a service
docker compose build Build services
docker compose restart Restart services
docker compose down Stop and remove all services, networks, and volumes defined by the Compose file

Docker Hub


Command Description
docker login Log in to Docker Hub
docker logout Log out from Docker Hub
docker search TERM Search Docker Hub for images
docker push IMAGE_NAME[:TAG] Push image to Docker Hub