This quick reference provides essential Docker commands for developers and devops. Learn how to list containers, run images, view logs, monitor resources, clean up unused resources, and more. Each command includes practical examples to help streamline your Docker workflow.

Docker Help

See all Docker commands and options:

docker --help

Get help for a specific command:

docker ps --help

docker ps

The docker ps command shows all running containers. It works like a task manager for Docker and displays the container ID, name, status, and port mappings.

docker ps

You can also use the -a option to view both running and stopped containers:

docker ps -a

docker run

The docker run command starts a new container from an image. Use options to control how it runs. For example, run NGINX in the background and map port 8080:

docker run -d -p 8080:80 nginx

docker logs

View output from a container (running or stopped) to debug or check status:

docker logs nginx

docker pull

Get images from Docker Hub or other registries. Pull the latest NGINX image:

docker pull nginx:latest

docker inspect

See detailed info about a container or image, including network, volumes, and environment variables:

docker inspect nginx

docker stats

Track real-time CPU, memory, network, and disk usage for all running containers:

docker stats

Monitor a specific container:

docker stats nginx

docker compose

Use Docker Compose to manage projects with multiple services. Start all services in the background:

docker compose up -d

Likewise, to stop all services:

docker compose down

docker system prune

Remove stopped containers, unused networks, dangling images, and build cache:

docker system prune

To remove everything, including unused volumes and all images:

docker system prune -a --volumes