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

Remove dangling volumes #40

Merged
merged 1 commit into from
Dec 1, 2016
Merged

Conversation

ymilki
Copy link
Member

@ymilki ymilki commented Dec 1, 2016

Sometimes volumes are left behind from docker-compose. docker volume ls -f dangling=true lists them all. These volumes aren't removed by dcgc because they aren't associated with any containers or images. They are left in /var/lib/docker/volumes indefinitely until removed.

@dnephin
Copy link
Contributor

dnephin commented Dec 1, 2016

LGTM

@ymilki
Copy link
Member Author

ymilki commented Dec 1, 2016

The only filter for volume deletion is dangling=True. docker volume inspect only provides the keys Name, Driver, Mountpoint, Label.

I suspect we may want either an exclude list or filters on Labels and Names (labels=null, name='^[a-z0-9]{64}$' perhaps) because volumes can be attached to containers.

@solarkennedy solarkennedy merged commit 4925cb0 into Yelp:master Dec 1, 2016
@Bert-R
Copy link

Bert-R commented Feb 9, 2017

I tried running Custodian with the new --dangling-volumes flag, like this:

docker run -i --rm -v /var/run/docker.sock:/var/run/docker.sock yelp/docker-custodian dcgc --dangling-volumes --max-container-age ...

But that causes the following error:

Getting all containers
Found 11 containers
Getting all containers
Found 11 containers
Getting all images
Found 33 images
Getting dangling volumes
Traceback (most recent call last):
  File "/usr/bin/dcgc", line 9, in <module>
    load_entry_point('docker-custodian==0.7.0', 'console_scripts', 'dcgc')()
  File "/code/docker_custodian/docker_gc.py", line 222, in main
    cleanup_volumes(client, args.dry_run)
  File "/code/docker_custodian/docker_gc.py", line 163, in cleanup_volumes
    dangling_volumes = get_dangling_volumes(client)
  File "/code/docker_custodian/docker_gc.py", line 80, in get_dangling_volumes
    log.info("Found %s dangling volumes", len(volumes))
TypeError: object of type 'NoneType' has no len()

Is it me? Or should I log an issue?

@dnephin
Copy link
Contributor

dnephin commented Feb 9, 2017

It sounds like it found no dangling volumes. Please open an issue about it.

@Bert-R
Copy link

Bert-R commented Feb 9, 2017

Done. See #41

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

Successfully merging this pull request may close these issues.

4 participants