Skip to content
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

Make kastenwesen cleanup more aggressive #62

Open
sedrubal opened this issue Jul 27, 2017 · 3 comments
Open

Make kastenwesen cleanup more aggressive #62

sedrubal opened this issue Jul 27, 2017 · 3 comments

Comments

@sedrubal
Copy link
Member

IMHO kastenwesen cleanup should remove

  • all containers, which are exited with status code 0 (we don't need to keep them for debugging / we shouldn't remove containers, which exited with a non zero exit status, because maybe we want to find out, why they exited)
  • all containers which stopped > n days ago
  • all dangling images, which are not used by any container any more and which don't have a tag any more

We could start with something like this:

docker ps -a -q --no-trunc --filter exited=0 | xargs --no-run-if-empty docker rm  # remove containers with exit code 0
docker images --no-trunc --format "{{.ID}} {{.Repository}} {{.Tag}}" | grep "<none>" | cut -d" " -f 1 | xargs --no-run-if-empty docker rmi  # clean images with no tag. Fails for images which are still be used by a container

By doing this, I could free 150 GB on our host brain. I already executed this from time to time.

@sedrubal
Copy link
Member Author

by the way docker has a command docker system prune in newer versions. But most probably it will take too long until ubuntu packages a more recent version of docker. So we need to implement this ourself.

@mgmax
Copy link
Member

mgmax commented Jul 27, 2017

Kastenwesen is currently not responsible for containers managed by someone/something else, and I think this is the correct design decision. This job is well done by docker-gc or docker's own commands. By default, if you don't pass other parameters, kastenwesen will keep containers younger than 31 days (for logging purposes) and their images (probably because it is impossible without removing the container).

AFAIK this works as designed, although 31 days is probably not the best default choice if you rebuild 10 GB of images every few days.

@sedrubal
Copy link
Member Author

ok, then we should use docker-gc. We should also add a note to the readme that kastenwesen cleanup does not clean up the entire system but that one should use docker-gc instead...

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

No branches or pull requests

2 participants