Stops running containers, then removes stopped containers, unused images, networks, build cache and volumes.
Caution. Destructive: deletes every unused volume, database data included. Leave out --volumes to keep volumes.
docker ps -q | xargs -r docker stop && docker system prune -a --volumes -f
cleanup, nuke, prune
Starts an interactive shell inside a running container.
docker exec -it <container-id> /bin/sh
Use /bin/bash if the image has it.
exec, shell
Shows a live stream of CPU/Memory usage.
docker stats
metrics, performance
Forces a completely fresh docker build bypassing all cached layers.
docker build --no-cache -t <image-name>:<tag> .
build, cache
Removes dangling images: untagged <none> layers left behind by rebuilds.
docker image prune -f
cleanup, images
Starts all services defined in a docker-compose.yml in the background.
docker compose up -d
compose, daemon
Extracts the internal IP address of a running docker container.
docker inspect -f '{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}' <container-id>
inspect, ip
Tails the logs of a docker container continuously.
docker logs -f <container-id>
logs, tail
Lists all Docker volumes on the host.
docker volume ls
volume, storage
Lists all Docker networks.
docker network ls
network, list
Tags a local image with a new name for pushing to a registry.
docker tag <image-id> <registry>/<repo>:<tag>
tag, registry
Pushes a tagged image to a container registry.
docker push <registry>/<repo>:<tag>
push, registry
Copies a file from inside a running container to the host.
docker cp <container-id>:/path/in/container /local/path
copy, files
Shows the build history and layer sizes of a Docker image.
docker history <image-name>
history, layers, debug
Writes an image to a tar file for offline transfer. Load it on the other host with docker load -i image.tar.
docker save -o image.tar <image-name>:<tag>
save, load, offline