-
Notifications
You must be signed in to change notification settings - Fork 18.6k
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
Implement a 'clean' command #928
Comments
It will be difficult to find a common definition of "clean". What if I have On Tue, Jun 18, 2013 at 5:04 PM, Guillaume J. Charmes <
|
Agreed, that's why it would make sense to take 2 dimensions for the clean command. The amount of time since the last start + the creation date. For instance, clean all containers that were created more than 30 days ago and which has not been started for 1 week. |
Note: the run duration is a good hint, too! (Chances are, that short-lived |
My favorite approach would be to improve 'docker images' and 'docker ps' On Tue, Jun 18, 2013 at 6:20 PM, Jérôme Petazzoni
|
This does seem like the kind of feature that everyone will want their own flavor of. Maybe the follow on feature is to make an equivalent of git aliases, so if someone wants to have a |
My proposal would be the following. A) allow for container tagging. Allow a (maybe unique) description (such as 'User info database') as well, which would make a container listing way more readable and informative. In my opinion, this would give a lot of value on top of the possibilities that the standard unix commands already offer. |
+1 to It's only going to get worse. |
Hey Nick, with the latest update (0.4.6), 'docker ps -a' should be fast On Sun, Jun 23, 2013 at 9:38 PM, Nick Stinemates
|
Confirmed. Upgrading helped a lot!
|
I'm of a split mind about the concept of a clean command. The comments saying it would be excellent are true, as are the ones suggesting that clean is something everyone will want their own flavor of. It seems like this has a lot of similarity to building a garbage collector... but there's no clear definition of what constitutes a strong reference, since it's possible for docker commands to want to refer to a container that ended an arbitrarily large distance ago in time or in subsequent container runs. |
Like I said before: what I want to see is improved ways of querying On Wed, Jun 26, 2013 at 3:55 PM, Eric Myhre notifications@github.comwrote:
|
Please have a look at #1077 I think that it provides a good way to handle temporary stuff without interferring with anything else. |
What about: |
@SeyZ This indeed works but it would remove only containers and all of them. |
I vote to implement a 'clean' command that works for both images and containers. Docker uses a lot of disk space and leaves a lot of stuff laying around. In an environment with limited disk space without resorting to cryptic bash scripts to clean out massive amounts of left over stuff from docker run and docker build. I have had to resort to the following bash scripts to clean up containers:
And this to clean up images:
My use case:
This series of steps on both a push box and application server eats up 1/2 to 2 g each time it is done both on the build box and the application server. On a 20GB machine, there is no room. It just seems to be something that should be part of the cannon of commands.. It should be easy, obvious and well documented. docker clean images or docker rm -a [--hard] Perhaps there is something critical I am missing about managing the containers and images that I can do to make this more manageable? |
you can do this right now: delete all contianers
|
I think the point is that docker seems to leave a lot of stuff lying around, both images and containers. I didn't know where all the space was going on my hard drive until I found some magic documented and undocumented things. I think it is important to really rethink the image build caching and whole graph thing. When I build a container, I should be able to disconnect it from all other associations so that it is independent from all those associations. I should be able to delete the cache baggage without worry that the image I just created is messed up. I should also be able to kill a container and have it completely disappear from the disk. An aside related to this issue: I am just trying to relate my experience as a new user. What was non-intuitive was the difference between a registry and a repository and the fact that when I build something or run something there is a lot of baggage laying around if you are constantly building and deleting images, and running and killing containers. For instance: here is a session where I delete stuff, as you can see, there is about 23 GB of space from left over docker containers killed off: From a full disk.... #docker ps -a | cut -c-12 | xargs docker rm Error: Impossible to remove a running container, please stop it first d46a31743a91 df -hFilesystem Size Used Avail Use% Mounted on |
We are convering to a solution to this problem with 2 improvements which are partially implemented in 0.6.6 and will continue in the 0.7 branch:
With this system, names can be used for reference-counting and garbage collection. If a container or image drops to 0 names, it can be safely removed. This will take care of leftover containers or images after a build, temporary containers etc. This means we will not need a "clean" command. Therefore I am closing this issue :) |
For those who want to clear down stopped docker containers, leave running ones, and want a zero exit code if there were no errors, use the following. We need it during an automated deploy, and were seeing the "Impossible to remove a running container" errors which come with the more "brute force" remove line given in comments above.
|
Not sure where this is at today, but thoughts FWTW: something like
*dangling means containers not in the current "branches". You can think of a tagged container as a named branch in git. All dependency |
@shykes a clean command is still needed to actually perform the garbage collection once the image runs to 0 reference count. |
@shykes I would also like to ask you to reconsider closing this ticket without a resolution such as suggested by @jbenet in #928 (comment). I run into serious disk space trouble after building and rebuilding images dozens of times. |
@shykes I agree with @dscho @drewcrawford - A |
This is particularly frustrating when automated deploys fail. |
my first contribution to this thread was a pul request for a session timout for docker containers (to clean up automatically) now that --rm is implemented i feel the need for a cleanup as less pressing. even though i have bash scripts for cleanup on every server which is kind of awkward. As this thread is not doing any progress... i think we should either suggest a new feature that fits in the big picture or let it go. |
There will always be new features to add, old bugs to fix, etc. (Note, there are over 900 issues, and over 100 PR's, and we merge or close over 100 PRs per week). Notably,
|
@cpuguy83 while i totally agree on not implementing a simple syntactic sugar, there is indeed something missing. I think whenever a closed issue gets much attention we should look at the cause, and if docker actually may be missing something needed. so please, lets look for constructive ideas to fill the gap with a feature that makes sense for every participant. |
For remote option of clearing unused Docker images , I'm part of a project trying to solve this (CloudSlang) using SSH/REST to clearing images from host, and still provide flexibility on the logic. We can elaborate it to give more "cleaning" capabilities... |
I think at the very least those handy commands for dangling images and stopped containers and the like should be placed into a visible area of the docs before this issue is closed. Perhaps related sections or a FAQ area, or even a "Maintaining Docker Long Term" section that can guide users in the various directions. That way we expose the variety of kinds of cleaning that can be done, with starting points to doing them. |
It's useful because the user does not clean out their images very often. Usually every 1-3 months. By that time everyone's forgotten the cmd to use. Wheras |
Ran into this problem (again) and had to spelunk through Docker issues (again) to fix it. +1 for syntactic sugar. |
@cpuguy83 Also, the "syntactic sugar" you propose is not actually correct. For example, your command This is not a hypothetical race condition. It affects nearly 50% of our cleanup runs (each takes tens of minutes to run, and we schedule a lot of tasks!) This makes it nearly impossible to write a correct implementation that can differentiate between failure modes, and the operator needs to sort it all out manually. Which sucks when you are maintaining a cluster of 100 machines which continually fill their disks. |
+1 to @stevenschlansker |
Perhaps there could be something like But also I'm thinking there shouldn't be any race issue when calling |
Definitely agree, image removal is quite racey. |
Thanks for looking. It's good to have validation that we have not (yet) completely lost our minds ;) |
@stevenschlansker thanks for that! We need to prevent adding features that are not strictly needed (or can be reasonably worked around in another way), but in this case you're right that the "workaround" was not a solution 👍 |
Here is another example of why this situation really sucks. Look at one of the best scripts I've found so far to "clean up" Docker: https://github.com/chadoe/docker-cleanup-volumes/blob/master/docker-cleanup-volumes.sh Not only is it hugely complicated, there have been multiple bugs which cause it to delete in-use volumes out from running containers: chadoe/docker-cleanup-volumes#19 And this is state of the art. I made the mistake of upgrading to Docker 1.8.3 yesterday and tripped this bug. Now this morning I've got about thirty angry users coming at me asking where their data is... but it's all gone :( |
Yeah. I also made the mistake of using a 3rd party tool to do a so-called 'clean' of my unused volumes. It just deleted all my docker volumes... Really didn't like that. |
A friend and I put together a script that may help some of you. The script runs a few filtered commands using Check it out and let us know what you think and open any issues with features you would like to see or fork and pull! |
alias docker-clean = 'docker rm |
This is handled by
To do them all at once:
Docs: (Commenting for anyone still reading this thread, e.g. linked here from StackOverflow.) |
It would be nice to have a command that cleans up docker:
This could be done via a new top level command 'docker clean' or via options to 'docker rm' and 'docker rmi'.
I think it would be better to have this server side than client side.
The text was updated successfully, but these errors were encountered: