Cleaning Up After Docker

  • With Development Use Docker can leave behind a lot of files
  • These files will grow and consume a lot of disk space
  • This is less of an issue on production systems where containers arent' being build and restarted all this time
  • There are 3 keys areas of house keeping:
    • Containers
    • Images
    • Volumes

Cleaning up containers

Kill all Running Docker Containers
- docker kill $(docker ps -q)

-$$(docker ps -q)
 q means quiet mode, then it will pass in a list of container id

Delete all stopped Docker Containers
- docker rm $(docker ps -a -q)

Cleaning up images

Remove a Docker Image
- docker rmi <image name>

Delete Untagged(dangling) Images
- docker rmi $(docker images -q -f dangling=true)

-f means filter 

Delete All Images
- docker rmi $(docker images -q)

Cleaning up volumes

Once a volume is no longer associated with a container, it is considered
dangling

Remove all dangling volumes
- docker volume rm $(docker volume ls -f dangling=true -q)

Note: Does not remove files from host system in shared volumes

results matching ""

    No results matching ""