Docker images and container cleanup

Stop and remove all containers:
docker stop $(docker ps -a -q)
docker rm $(docker ps -a -q)
Remove containers according to a pattern:
docker ps -a | grep "pattern" | awk ‘{print $3}’ | xargs docker rmi
Remove one or more specific images:
docker rmi Image Image
Purging All Unused or Dangling Images, Containers, Volumes, and Networks
docker system prune -a
REF:
https://www.digitalocean.com/community/tutorials/how-to-remove-docker-images-containers-and-volumes

pull and start an image:
docker pull zhuby1973/php:1
docker run -p 82:80 zhuby1973/php:1
you can run it as daemon with -d option:
docker run -d -p 82:80 zhuby1973/php:1

Leave a Reply

Your email address will not be published. Required fields are marked *