New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

To free disk space after removing a container #7758

Closed
muchweb opened this Issue Aug 27, 2014 · 17 comments

Comments

Projects
None yet
9 participants
@muchweb
Copy link
Contributor

muchweb commented Aug 27, 2014

  1. I have run mongo container
  2. Container requires about 4GB to run, which was reserved
  3. I have stopped and removed a container using docker stop and docker rm
  4. Disk space is still taken in /var/lib/docker and there is no obvious way to free it

@muchweb muchweb changed the title To free space after removing a container To free disk space after removing a container Aug 27, 2014

@LK4D4

This comment has been minimized.

Copy link
Contributor

LK4D4 commented Aug 27, 2014

@muchweb Could you try to remove with -v?

@muchweb

This comment has been minimized.

Copy link
Contributor Author

muchweb commented Aug 27, 2014

@LK4D4 this have freed the space. Why it is not a default behaviour?

This seems confusing, because once container is removed using docker rm, the only simple way to free the space that I found is to stop the service and run sudo rm -rf /var/lib/docker/vfs.

@LK4D4

This comment has been minimized.

Copy link
Contributor

LK4D4 commented Aug 27, 2014

@muchweb :D I think now we can't find person who knows why. But I think we'll fix this in next release.

@muchweb

This comment has been minimized.

Copy link
Contributor Author

muchweb commented Aug 27, 2014

@LK4D4 alright, I thought there was a good reason.

@cpuguy83

This comment has been minimized.

Copy link
Contributor

cpuguy83 commented Aug 28, 2014

@muchweb Reason would be that data is important, especially in production.
I think setting -v=true as the default is a dangerous thing to do.

Better to create a way to actually manage volumes.

@frank-dspeed

This comment has been minimized.

Copy link

frank-dspeed commented Aug 28, 2014

i aggree with cpu guy main priority should be now volume management it would be realy usefull to have a better view of volumes maybe --viz switch like the images.

@muchweb

This comment has been minimized.

Copy link
Contributor Author

muchweb commented Aug 28, 2014

@cpuguy83 I partially aggree. It is dangerous to first delete container and then look for it's data after anyways. In production, location of important files should be explicetly set up. Additionally, volumes are not deleted until container itself is specifically removed.

Not deleting volumes with containers by default, creates non-obvious behaviour and can quickly fill up the space (like mongo image that takes 4GB of hidden space each run).

Deprecating -v flag, setting it to -v=true and introducing new, disabling option may solve both issues. What do you think?

@getvictor

This comment has been minimized.

Copy link
Contributor

getvictor commented Oct 9, 2014

Is there a way to free up disk space after the container was already removed?

Is it OK to simply delete a directory like /var/lib/docker/aufs/diff/aca49675ea2ee5b2be5711374422fb9db9cec17360d6988eddbb6a385508a3a5?

@goloroden

This comment has been minimized.

Copy link

goloroden commented Jan 15, 2015

Any update on this?

@cpuguy83

This comment has been minimized.

Copy link
Contributor

cpuguy83 commented Jan 15, 2015

@goloroden I don't think we will automatically remove volumes when the container is removed, it's dangerous and a breaking change.

@unclejack

This comment has been minimized.

Copy link
Contributor

unclejack commented Feb 2, 2015

docker rm -v needs to be used in order to remove a container's volumes. These volumes can be looked up and removed by hand. However, @cpuguy83 will continue to work on volumes and managing volumes should become easier.

There are more issues like this one which are caused by leftover volumes. I'm going to close this issue now.

@unclejack unclejack closed this Feb 2, 2015

@muchweb

This comment has been minimized.

Copy link
Contributor Author

muchweb commented Feb 2, 2015

These volumes can be looked up and removed by hand.

@unclejack, could you please specify the exact way of removing leftover volumes, once the container is deleted?

This issue was about the lack of obvious way to fix it, thus not resolved.

@thaJeztah

This comment has been minimized.

Copy link
Member

thaJeztah commented Feb 2, 2015

@muchweb There's a proposal to add volume management in docker. That proposal would enable you to list (and delete) volumes, both "in use" and "orphaned" (left-over) volumes. The proposal can be found here: #8484.

However, that proposal isn't accepted yet, but the author of that proposal also created an external tool, called "docker-volumes" that offers the same functionality. Docker-volumes can be found here: https://github.com/cpuguy83/docker-volumes and the easiest way to run it is to download a binary from the releases page

@muchweb

This comment has been minimized.

Copy link
Contributor Author

muchweb commented Feb 2, 2015

@thaJeztah, thank you! 👍 docker-volumes looks very handy.

@frank-dspeed

This comment has been minimized.

Copy link

frank-dspeed commented Feb 2, 2015

alternate is my more simply docker-volume-cleanup util from http://github.com/dockerimages/docker-tools

example output:

Volumes (in use) <<
/
/opt/fileserver/adt-2/DATA/solr
/opt/fileserver/adt-wp/DATA
/opt/fileserver/adt-wp/DATA/config/default.vcl
/opt/fileserver/adt-wp/DATA/mysql
/opt/fileserver/adt-wp/DATA/www
/opt/fileserver/docker-registry/tmp
/opt/fileserver/gitlab/DATA/data/repositories

Orphaned Volumes <<
/var/lib/docker/vfs/dir/029e03c746e4e7969852c4ae0e27d72d68f3f829a6d5d4e536bbe11ca04ac53d
/var/lib/docker/vfs/dir/02d477b9638de43fc992e31289e00de433031839d1bcc372bc4419eb1d528bc7
/var/lib/docker/vfs/dir/03b1fa68377931a87f320e1e08b4e2c83c2e718f96cbbb864974840dc521b51b
/var/lib/docker/vfs/dir/03db5c40a3ff0d0dfec3641eb7a76284858a7d3601e079b25e730fd624d24e23
/var/lib/docker/vfs/dir/04bdacfa87ee08d87994759d3116bca09b244c0be66a126203fd1686336eae0b
/var/lib/docker/vfs/dir/081a5b548408b020db4e52eb0a88e54e8b82ab76aa3cb276593da39822411d4b
/var/lib/docker/vfs/dir/09bc6ab2117e38de173e6a8217de582cde3578e0ddb060382b90362dc1ea1b2b
/var/lib/docker/vfs/dir/0a21126b56f7ae9e63e23943cdb945042227b1b96ce866d9bb704c00e57171c6
/var/lib/docker/vfs/dir/0bbe471ae2e0ec0e5cec84ba44e9c353b661a923d77931b1f1354b98304e33d7
/var/lib/docker/vfs/dir/0c515eee24a1f96dacc26bb6d40f20945a4c8e3033bb8d34076ede5cf978ca6e
/var/lib/docker/vfs/dir/0ce2a13a25e3ad3bf7e6f3489c65d964de5be62e280a78a9155990ced4ebc4ff
/var/lib/docker/vfs/dir/0e851ad03b6f82b4aacd75ad00b34ca97a436a9a926757e4af150d23cc2814c0
/var/lib/docker/vfs/dir/0ed66974fb24c447e5346a23d17aab8bc9dd3ed075ce31212a20fb8ed7068933

use docker-volume-cleanup -f to delet all orphaned volumes

@wattletimber

This comment has been minimized.

Copy link

wattletimber commented Jun 6, 2016

Hi Guys am ahving serios my docker container is increasing everyday by 1 gig how can i create space? see image below
screen shot 2016-06-06 at 6 43 50 am

@thaJeztah

This comment has been minimized.

Copy link
Member

thaJeztah commented Jun 6, 2016

@wattletimber if that container does a lot of logging, it may be the JSON log file that keeps growing; make sure you start your container with --log-opt max-size=[something] (optionally with --log-opt max-files=[something]. See https://docs.docker.com/engine/admin/logging/overview/#json-file-options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment