docker(1)
Manage Docker containers, images, networks, and volumes from the command line.
Synopsis
docker [OPTIONS] COMMAND [ARG...]Description
Docker is a containerization platform that allows you to package applications and their dependencies into isolated, lightweight containers. The docker command-line interface (CLI) provides tools to build, run, manage, and distribute containers and images.
Docker commands are organized into management commands (like docker container, docker image) and legacy commands (like docker run, docker build). Both forms work identically.
Common options
| Flag | What it does |
|---|---|
-v, --version | Show Docker version information |
-H, --host | Docker daemon socket or host to connect to (e.g., unix:///var/run/docker.sock or tcp://localhost:2375) |
-D, --debug | Enable debug mode for verbose output |
--config | Location of client config files (default: ~/.docker) |
-l, --log-level | Set logging level (debug, info, warn, error, fatal) |
--tlsverify | Use TLS and verify the remote server certificate |
--tlscacert | Path to CA certificate file for TLS verification |
-h, --help | Show help text for docker or a specific command |
Examples
Run an nginx container in detached mode, mapping port 8080 on host to port 80 in container, naming it 'webserver'
docker run -d -p 8080:80 --name webserver nginxList all containers (running and stopped) with their IDs, names, status, and ports
docker ps -aBuild a Docker image from a Dockerfile in the current directory, tagging it as 'myapp:1.0'
docker build -t myapp:1.0 .Open an interactive bash shell inside a running container
docker exec -it container_id /bin/bashStream and follow the logs of a running container in real-time
docker logs --follow container_idDownload the Ubuntu 20.04 image from Docker Hub
docker pull ubuntu:20.04List all local Docker images with their repository, tag, image ID, and size
docker imagesRemove all stopped containers
docker rm $(docker ps -aq)