docker --versionOutputs the installed Docker CLI version to verify installation
The Docker CLI: build, run and inspect containers and images, and audit their configuration, mounts, capabilities and networks.
sudo apt install docker.iodocker --versionOutputs the installed Docker CLI version to verify installation
docker versionDisplays detailed version information for both Docker Client and Server
docker infoShows system-wide information including kernel version, storage driver, and container counts
docker helpLists all available commands and global options for the Docker CLI
docker loginAuthenticates the Docker client against a container registry
Example
docker login registry.example.comdocker searchSearches Docker Hub for public images with an optional limit
Example
docker search nginx --limit 5docker pullDownloads a specific image tag from a registry to the local cache
Example
docker pull alpine:latestdocker imagesLists all top-level images currently stored locally
docker image ls -aLists all local images including intermediate image layers
docker tagCreates a new tag for an existing local image
Example
docker tag nginx:latest myrepo/nginx:v1docker pushUploads a locally tagged image to a remote registry
Example
docker push myrepo/nginx:v1docker rmiRemoves one or more images from the local storage
Example
docker rmi alpine:latestdocker rmi -fForces the removal of an image even if containers are using it
Example
docker rmi -f alpine:latestdocker image pruneRemoves all unused images, not just dangling ones
Example
docker image prune -adocker historyShows the history of layers and commands used to build an image
Example
docker history nginx:latestdocker saveExports an image to a tar archive for offline transfer
Example
docker save -o myimage.tar nginx:latestdocker loadLoads an image from a tar archive into the local docker engine
Example
docker load -i myimage.tardocker createCreates a new container layer but does not start it
Example
docker create --name webserver nginxdocker startStarts one or more stopped containers
Example
docker start webserverdocker run -itCreates and starts a container in interactive mode with a TTY
Example
docker run -it ubuntu /bin/bashdocker run -dRuns a container in detached mode in the background
Example
docker run -d nginxdocker run --rmRuns a container that automatically removes itself upon exit
Example
docker run --rm alpine echo 'hello'docker psLists currently running containers
docker ps -aLists all containers including stopped ones
docker stopGracefully stops a running container by sending SIGTERM
Example
docker stop webserverdocker killForcibly stops a container by sending SIGKILL
Example
docker kill webserverdocker restartStops and then immediately starts a container
Example
docker restart webserverdocker pausePauses all processes within one or more containers
Example
docker pause webserverdocker unpauseResumes all processes within one or more paused containers
Example
docker unpause webserverdocker rmRemoves a stopped container from the system
Example
docker rm webserverdocker rm -fForcibly removes a running container
Example
docker rm -f webserverdocker execRuns a new command inside a running container interactively
Example
docker exec -it webserver /bin/bashdocker attachAttaches local standard input, output, and error to a running container
Example
docker attach webserverdocker logsFetches the logs of a container
Example
docker logs webserverdocker logs -fStreams the logs of a container in real-time
Example
docker logs -f webserverdocker cp container to hostCopies a file from a container to the host filesystem
Example
docker cp webserver:/etc/nginx/nginx.conf ./docker cp host to containerCopies a file from the host filesystem into a container
Example
docker cp ./index.html webserver:/usr/share/nginx/html/docker inspectReturns low-level information on a container or object in JSON format
Example
docker inspect webserverdocker statsDisplays a live stream of container resource usage statistics
docker topDisplay the running processes of a container
Example
docker top webserverdocker diffInspects changes to files or directories on a container's filesystem
Example
docker diff webserverdocker portLists port mappings for the container
Example
docker port webserverdocker network lsLists all networks created by Docker
docker network createCreates a new bridge network for containers to communicate
Example
docker network create --driver bridge my-netdocker network inspectDisplays detailed information about a network
Example
docker network inspect my-netdocker network connectConnects a running container to a network
Example
docker network connect my-net webserverdocker network disconnectDisconnects a container from a network
Example
docker network disconnect my-net webserverdocker network rmRemoves one or more networks
Example
docker network rm my-netdocker run -pMaps host port 8080 to container port 80
Example
docker run -d -p 8080:80 nginxdocker run --network hostRuns container using the host's networking stack directly
Example
docker run --network host nginxdocker run --dnsSets custom DNS servers for the container
Example
docker run --dns 8.8.8.8 nginxdocker volume lsLists all Docker volumes
docker volume createCreates a new named volume for persistent storage
Example
docker volume create my-datadocker volume inspectDisplays detailed information about a volume
Example
docker volume inspect my-datadocker run -v volumeMounts a named volume to a path inside the container
Example
docker run -v my-data:/data nginxdocker run -v bindBinds a host directory to a path inside the container
Example
docker run -v /host/path:/container/path nginxdocker volume rmRemoves a Docker volume
Example
docker volume rm my-datadocker volume pruneRemoves all unused local volumes
docker buildBuilds an image from a Dockerfile in the current directory
Example
docker build -t myapp:v1 .docker build fileBuilds an image using a specific Dockerfile filename
Example
docker build -f Dockerfile.dev .docker build no-cacheBuilds an image without using the build cache
Example
docker build --no-cache -t myapp .docker build argsPasses build-time variables to the Dockerfile
Example
docker build --build-arg VERSION=1.0 .docker build targetBuilds only up to a specific stage in a multi-stage Dockerfile
Example
docker build --target production .docker run --userRuns the container as a specific non-root user ID and group ID
Example
docker run --user 1000:1000 alpine whoamidocker run --read-onlyMounts the container's root filesystem as read-only
Example
docker run --read-only alpinedocker run --cap-dropDrops all Linux capabilities from the container for hardening
Example
docker run --cap-drop ALL alpinedocker run --cap-addAdds specific Linux capabilities to the container
Example
docker run --cap-add NET_ADMIN alpinedocker run --privilegedRuns container with full host root capabilities (Use with extreme caution)
Example
docker run --privileged ubuntudocker run --security-optPrevents the container processes from gaining new privileges
Example
docker run --security-opt no-new-privileges alpinedocker run --memoryLimits the memory usage of the container
Example
docker run --memory 512m nginxdocker run --cpusLimits the container to use 50% of a CPU core
Example
docker run --cpus 0.5 nginxdocker run --pids-limitLimits the number of processes a container can start
Example
docker run --pids-limit 100 alpinedocker network create overlayCreates a multi-host overlay network (requires Swarm mode)
Example
docker network create -d overlay swarm-netdocker run --mac-addressSets a static MAC address for the container network interface
Example
docker run --mac-address 92:d0:c6:0a:29:33 alpinedocker run --add-hostAdds a custom entry to the container's /etc/hosts file
Example
docker run --add-host db-local:10.0.0.5 alpinedocker network create -d overlayGenerates a distributed overlay network allowing swarm containers deployed on completely different physical servers to communicate securely natively.
Example
docker network create -d overlay multi_host_netdocker logs --tailShows only the last 10 lines of container logs
Example
docker logs --tail 10 webserverdocker logs --timestampsAdds timestamps to the log output
Example
docker logs --timestamps webserverdocker eventsStreams real-time events from the Docker daemon
docker events filterFilters system events to show only container termination events
Example
docker events --filter 'event=die'docker volume create optionsCreates a volume with specific driver options
Example
docker volume create --driver local --opt type=tmpfs --opt device=tmpfs foodocker run --mountUses the explicit mount syntax for clearer bind mounting
Example
docker run --mount type=bind,source=/data,target=/data nginxdocker run --tmpfsMounts a temporary filesystem in memory that is removed when container stops
Example
docker run --tmpfs /run alpinedocker context lsLists available Docker contexts for managing multiple endpoints
docker context createCreates a context to manage a remote Docker daemon via SSH
Example
docker context create remote --docker host=ssh://user@remote-hostdocker context useSwitches the Docker CLI to operate against a specific context
Example
docker context use remotedocker compose upBuilds and starts containers defined in docker-compose.yml
Example
docker compose up -ddocker compose downStops and removes containers and networks defined in docker-compose.yml
docker compose logsViews output from containers defined in the compose file
Example
docker compose logs -fdocker exportExports a container's filesystem as a tar archive (without history)
Example
docker export webserver > fs.tardocker importImports the contents from a tarball to create a filesystem image
Example
docker import fs.tar myimage:importeddocker commitCreates a new image from a container's changes (Not recommended for production)
Example
docker commit webserver myimage:snapshotdocker waitBlocks until a container stops, then prints its exit code
Example
docker wait webserverdocker inspect formatExtracts specific data like IP address using Go templates
Example
docker inspect --format='{{.NetworkSettings.IPAddress}}' webserverdocker inspect mountsExtracts detailed mounting information for security audit
Example
docker inspect --format='{{json .Mounts}}' webserverdocker diff checkChecks for unauthorized file modifications inside a compromised container
Example
docker diff suspicious_containerdocker history no-truncViews full command history to find secrets or bad commands in image build
Example
docker history --no-trunc nginx:latestdocker run --ulimitSets specific ulimits like open file descriptors for the container
Example
docker run --ulimit nofile=1024:1024 alpinedocker run --deviceAdds a specific host device to the container
Example
docker run --device=/dev/snd:/dev/snd alpinedocker run --cgroup-parentSpecifies the parent cgroup for the container to inherit limits
Example
docker run --cgroup-parent=/my-cgroup alpinedocker run --runtimeSpecifies a custom OCI runtime for the container
Example
docker run --runtime=runc alpinedocker run --initRuns an init process inside the container to forward signals and reap zombies
Example
docker run --init alpinedocker run --entrypointOverwrites the default ENTRYPOINT of the image
Example
docker run --entrypoint /bin/sh nginxdocker run --workdirSets the working directory inside the container
Example
docker run -w /app alpine pwddocker run --envSets environment variables inside the container
Example
docker run -e MYVAR=production alpine envdocker run --env-fileReads environment variables from a file
Example
docker run --env-file ./env.list alpine envdocker run --health-cmdDefines a command to run to check container health
Example
docker run --health-cmd='curl -f http://localhost/' nginxdocker run --health-intervalSets the time between health checks
Example
docker run --health-interval=30s nginxdocker run --cidfileWrites the container ID to a file upon startup
Example
docker run --cidfile ./container.id nginxdocker container inspect stateQuickly retrieves the exit code of a crashed container
Example
docker inspect --format='{{.State.ExitCode}}' webserverdocker cp forensicsExtracts application logs for forensic analysis without entering the container
Example
docker cp webserver:/var/log/app.log ./evidence/docker compose up -dStarts all services defined in a docker-compose.yml in detached background mode.
docker compose down -vStops all compose services and forcefully removes the named volumes attached to them, performing a complete clean state wipe.
docker compose psLists the current status, ports, and health of containers strictly managed by the local docker-compose configuration.
docker compose logs -f <service>Tails and follows the logs explicitly for one isolated microservice defined inside the compose stack.
Example
docker compose logs -f webdocker swarm initInitializes the machine as a Docker Swarm Master Manager node, generating the join tokens required for worker nodes.
Example
docker swarm init --advertise-addr <ip>docker swarm join-token workerReveals the strict command and cryptographic token required for a remote machine to securely join this specific swarm.
docker node lsLists all active nodes participating in the swarm matrix, their reachability status, and whether they are managers or workers.
docker service createDeploys a horizontally scaled service directly into the swarm, automatically load balancing requests across 3 isolated replicas.
Example
docker service create --replicas 3 --name web_server nginxdocker service logs <serviceName>Aggregates and tails the logs from all scattered swarm replicas belonging to this service into a single unified output stream.
Example
docker service logs web_serverdocker buildx create --useSpins up and activates a new sophisticated BuildKit environment unlocking multi-architecture compiling capabilities.
docker buildx build --platformCross-compiles the current Dockerfile for multiple disparate architectures (Apple Silicon / Intel) simultaneously and pushes the manifest to the registry.
Example
docker buildx build --platform linux/amd64,linux/arm64 -t app:latest --push .docker volume prune -aDangerously destroys every single data volume on the system that is not currently actively mounted by a running container.
Example
docker volume prune -a --forcedocker top <container_id>Maps internal container PIDs directly to their corresponding Host Operating System PIDs bridging the namespace isolated visibility.
Example
docker top 1234abcddocker cp <container_id>:<path> <local_path>Forcefully circumvents mounting architectures to directly extract or inject raw files out of a running container's sandbox.
Example
docker cp 12ab:/var/log/nginx/access.log ./A script that checks a Docker host against dozens of CIS Docker Benchmark best practices for production deployments.
Aqua’s all-in-one scanner for vulnerabilities, misconfigurations, secrets and licenses in container images, filesystems, repositories, IaC and Kubernetes.
The Kubernetes command line: inspect and manage clusters, workloads, RBAC and secrets — and check what an identity is allowed to do.