docker versionUseful to confirm API compatibility and engine version before troubleshooting.
Comprehensive Docker Engine CLI reference for images, containers, networks, volumes, registries, contexts, and cleanup.
Core Docker client and daemon inspection commands.
docker versionUseful to confirm API compatibility and engine version before troubleshooting.
Display engine-wide diagnostic and configuration information.
docker infoShows storage driver, runtime, cgroup driver, registries, and resource counts.
docker --helpUse this to discover object-oriented commands such as `docker container`, `docker image`, and `docker network`.
docker context lsContexts let you switch between local, remote, or cloud-managed endpoints.
docker context use defaultUseful when working across local and remote engines.
Authenticate to a registry such as Docker Hub or a private registry.
docker loginStores credentials via configured credential helper or config store.
docker logoutGood hygiene on shared machines.
docker search nginxUseful for discovering official images and community variants.
Pull, tag, inspect, save, and manage images.
docker pull nginx:latestPin a specific tag or digest in production workflows.
docker push ghcr.io/acme/web:1.0.0Requires authentication and repository permissions.
docker imagesEquivalent to `docker image ls`.
List local images using the image management namespace.
docker image lsObject-oriented form that groups image subcommands together.
docker image history nginx:latestHelpful for understanding image growth and Dockerfile output.
docker image inspect nginx:latestGreat for checking entrypoint, environment, architecture, and labels.
docker image rm nginx:latestWill fail if the image is referenced by existing containers unless forced.
docker rmi -f nginx:latestUseful when tags or stopped containers keep the image referenced.
docker image pruneReclaims space from untagged layers left after rebuilds.
docker image prune -aMore aggressive than pruning only dangling images.
docker tag myapp:dev ghcr.io/acme/myapp:1.0.0Use tags to prepare images for different registries or release channels.
docker save -o myapp.tar myapp:1.0.0Useful for air-gapped environments or offline transfer.
docker load -i myapp.tarComplements `docker save`.
docker image import rootfs.tar myimage:rootfsUseful for creating simple images from exported root filesystems.
docker image build -t myapp:dev .Equivalent to `docker build`.
Create a new image from container changes.
docker commit mycontainer myimage:debugHandy for debugging, but prefer Dockerfiles for repeatable builds.
docker image push --all-tags ghcr.io/acme/myappUseful during migrations or synchronized releases.
docker manifest inspect alpine:latestHelpful for multi-platform images and digests.
Create, run, inspect, and manage containers.
docker run nginx:latestShorthand for create + start with default options.
docker run -d --name web nginx:latestDetached mode is common for services and daemons.
docker run -it ubuntu:24.04 bashUseful for exploration, debugging, and ephemeral workspaces.
docker run -d -p 8080:80 nginx:latestMaps host port 8080 to container port 80.
docker run -e NODE_ENV=production myapp:latestCan be repeated or loaded from a file with `--env-file`.
docker run --env-file .env myapp:latestHandy for local development and repeatable container starts.
docker run -v "$PWD":/app -w /app node:20 npm testGood for local dev, compilers, and ad hoc tooling.
docker run --mount type=bind,src="$PWD",dst=/app myapp:latestLong-form mount syntax is more explicit and extensible than `-v`.
Automatically remove the container after it exits.
docker run --rm alpine:latest echo helloIdeal for short-lived commands and one-off jobs.
Create a container but do not start it yet.
docker create --name web nginx:latestUseful when you want to inspect or stage before execution.
docker start webUse `-a` to attach immediately after start.
docker stop webSends SIGTERM then SIGKILL after the timeout.
docker kill webSends SIGKILL by default or a custom signal with `-s`.
docker restart webUseful after config changes or transient failures.
docker pause webUseful for testing or temporarily freezing workloads.
docker unpause webCounterpart to `docker pause`.
docker psEquivalent to `docker container ls`.
docker ps -aUseful for finding exited containers and previous runs.
docker container lsObject-oriented alias for `docker ps`.
Run a command in a running container.
docker exec -it web shA standard way to inspect or debug a live container.
docker attach webUseful for foreground processes, but `docker exec` is often safer.
docker logs webPair with `-f` to follow logs in real time.
docker logs -f --tail=100 webGreat for watching startup and runtime behavior.
Display running processes inside a container.
docker top webUseful for checking which process tree is active.
Stream live CPU, memory, network, and block I/O usage.
docker statsGood for spotting runaway or memory-hungry containers.
docker cp ./config.yml web:/etc/myapp/config.ymlUseful for debugging or quick experiments.
docker cp web:/var/log/nginx/access.log ./access.logGood for extracting logs and generated artifacts.
docker rename web web-oldHelpful when rotating or staging replacements.
docker rm webUse `-f` to remove a running container.
docker rm -f webEquivalent to killing then removing it.
docker container pruneHelpful for reclaiming clutter and space.
Deep inspection, diffing, events, and daemon-side diagnostics.
docker inspect webInspect networking, mounts, environment, and restart policy.
docker inspect -f '{{.NetworkSettings.IPAddress}}' webGreat for extracting just the data you need in scripts.
Show filesystem changes in a container since it started.
docker diff webUseful for debugging and understanding mutable writes.
docker eventsHelpful for automation, debugging, and understanding lifecycle actions.
docker events --filter type=container --filter event=startUseful when troubleshooting a specific resource kind.
docker port webQuickly verify how container ports map to host ports.
Block until a container exits and print its exit code.
docker wait webUseful in scripts that need to synchronize with a container run.
Update resource limits on a running container.
docker update --memory 512m --cpus 1.5 webCommon for tuning CPU and memory without recreating the container.
Show events from the past hour and continue streaming.
docker events --since 1hHelpful during incident analysis.
Manage Docker networks and service connectivity.
docker network lsShows built-in networks and user-defined bridges or overlays.
docker network create app-netUser-defined bridges provide automatic DNS between containers.
docker network create --subnet 172.20.0.0/16 app-netUseful when you need predictable IP ranges.
docker network inspect app-netInspect connected endpoints, subnets, and driver settings.
docker network connect app-net webLets a container participate in multiple networks.
docker network disconnect app-net webUseful when changing topology or isolating a workload.
docker network rm app-netWill fail if the network is still in use.
docker network pruneHelps keep the engine clean after many experiments.
docker run -d --name api --network app-net myapi:latestUseful for service discovery between app containers.
Create and manage named volumes and mount strategies.
docker volume lsNamed volumes are managed by the engine and survive container removal.
docker volume create pgdataUseful for databases and persistent application state.
docker volume inspect pgdataInspect mountpoint, driver, labels, and options.
docker volume rm pgdataWill fail if the volume is still attached unless forced by removing containers first.
docker volume pruneUseful after many test runs that leave dangling data.
docker run -d --name db -v pgdata:/var/lib/postgresql/data postgres:16Common for persistent databases and stateful services.
docker run --mount type=bind,src="$PWD/config",dst=/app/config,readonly myapp:latestGood for config files that should not be changed by the container.
docker run --tmpfs /tmp:rw,noexec,nosuid,size=64m myapp:latestUseful for ephemeral sensitive temp data.
Space usage, pruning, and lifecycle cleanup.
Display disk usage by images, containers, volumes, and build cache.
docker system dfGreat for understanding where Docker is using space.
Remove stopped containers, unused networks, dangling images, and build cache.
docker system pruneGood periodic cleanup for development machines.
docker system prune -a --volumesBe careful: this can remove data you expected to keep.
docker builder pruneUseful when BuildKit caches become large.
Remove all unused build cache, not only dangling records.
docker builder prune -aCan reclaim significant disk space after many builds.
Registry tagging, digest pinning, and manifest workflows.
docker pull nginx@sha256:<digest>Prefer digests when you need strict reproducibility.
docker run nginx@sha256:<digest>Prevents silent changes behind mutable tags such as `latest`.
Display the digests associated with a local image.
docker image inspect nginx:latest --format '{{json .RepoDigests}}'Useful when promoting or pinning builds.
Create a local manifest list from multiple platform images.
docker manifest create ghcr.io/acme/myapp:1.0.0 ghcr.io/acme/myapp:1.0.0-amd64 ghcr.io/acme/myapp:1.0.0-arm64Part of a multi-architecture publishing workflow.
Annotate a manifest list entry with platform metadata.
docker manifest annotate ghcr.io/acme/myapp:1.0.0 ghcr.io/acme/myapp:1.0.0-arm64 --arch arm64Useful when building a multi-platform image index manually.
docker manifest push ghcr.io/acme/myapp:1.0.0Lets clients pull the right image for their platform automatically.
Remote engine contexts and image trust basics.
Create a named context that targets a specific Docker endpoint.
docker context create prod --docker host=ssh://user@serverVery convenient for operating remote engines over SSH.
docker context inspect prodUseful to confirm host, TLS, and metadata settings.
docker context rm prodCleans up no-longer-used targets from your local client.
docker trust inspect alpine:latestRelevant in environments using Docker Content Trust / Notary workflows.
docker trust sign acme/myapp:1.0.0Useful in security-sensitive promotion pipelines.