Build an image:
docker build -t myimage .
Build an image, deleting the old one:
docker rmi myimage && docker build -t myimage .
Build an image, and print all the steps:
docker build --progress=plain -t myimage .
Run container from image, with port forwarding:
docker run -p 80:80 myimage
Run container for debugging purposes, replacing the entrypoint with a shell:
docker run --rm -it --entrypoint bash myimage
List all images:
docker image ls
List all containers: (The -a flag is to show stopped containers as well)
docker container ls -a
List all docker images and containers and file sizes:
docker system df -v
Show the history of an image:
docker history myimage
Dangling images are untagged and not needed by any tagged images. Unused image are not needed by any existing containers.
Delete stopped containers:
docker container prune
Remove dangling images:
docker image prune
Remove unused images:
docker image prune -a
Remove build cache:
docker builder prune