Why doesn't removing containers and docker images free up storage space on Windows? How to fix it?

Problem:

When I load and run containers, they continue to take up more and more space. I found suggestions for cleaning unused containers and images, and I did it. Guess what? They eat up even more disk space!

What I have found so far:

It is associated with the .docker\machine\machines\default\disk.vmdk . It is only increasing!

Disk.vmdk log:

  size (MB) 1. with 2 images 1,376 2. downloading a new image X ? 3. running X as Y 2,963 4. removing Y 2,963 5. removing X 3,106 6. removing all the images 3,126 

The only fix I have found so far is running docker-machine rm default , which removes the virtual machine. The problem is that I have to download all the images again. There must be a better fix. Can someone explain:

  • What's happening?
  • How to fix it?
+5
source share
1 answer

The images you are using may use volumes. If they do, removing the container will not help. You must also delete volumes. To do this, you must specify the -v flag when removing the container

 docker rm -v <container name or container id> 

Depending on the version of your docker, you will get a few more available commands. Check out this SO stream for more information. You can learn more about lost volumes in this SO thread.

+1
source

Source: https://habr.com/ru/post/1247741/


All Articles