Repository navigation
Add volumes cleanup - #142
Conversation
Add volumes cleanup
exclude volumes removal
add VOLUME_DELETE_ONLY_DRIVER
|
Is there a timeline on which this would be merged and? |
|
@imkin This is integrated in my fork https://github.com/rccrdpccl/docker-gc/ , but there is no timeline to merge it in this repo |
sgerrand
left a comment
There was a problem hiding this comment.
Some typos here and there, but the functionality is useful. We've got workarounds in place to do this on top of docker-gc. It'd be great to have this exist within the app itself.
| drunk_goodall | ||
| ``` | ||
|
|
||
| ### Excluding Volumes From Gargbage Collection |
|
|
||
| ### Excluding Volumes From Gargbage Collection | ||
|
|
||
| There can be occasions where you dont want to remove a dangling volume. |
| ### Excluding Volumes From Gargbage Collection | ||
|
|
||
| There can be occasions where you dont want to remove a dangling volume. | ||
| In such case, you can create `/etc/docker-gc-exclude-volumes` (or specify |
There was a problem hiding this comment.
"To enable this functionality you can create a file named /etc/docker-gc-exclude-volumes"
|
@sgerrand Thanks for the feedback, I have fixed the typos now! |
|
Hoping to add support for this feature in the official spotify/docker-gc binary/docker image. Anything stopping getting this in? |
| fi | ||
| else | ||
| if [[ -z "$VOLUME_DELETE_ONLY_DRIVER" ]]; then | ||
| $DOCKER volume ls --filter "dangling=true" -q | grep -v -f $EXCLUDE_VOLUMES_IDS_FILE > volumes.reap |
There was a problem hiding this comment.
My only suggestion would be to either check to make sure $EXCLUDE_VOLUMES_IDS_FILE exists (if not, don't bother grepping) or follow the examples set previously with the image/container excludes logic where if file doesn't exist, filepath just set to /dev/null. (See here)
That way, we can maintain tradition of opting in for volume removal but not having to supply an exclusion file (in such case, we'd assume all unused/dangling volumes are intended to be removed.)
Otherwise, definitely excited for this addition! (Have been testing locally w/ forked ricc/docker-gc image...)
There was a problem hiding this comment.
Ok, I've gone for setting filepath to /dev/null. Please let me know if I can improve it further!
There was a problem hiding this comment.
Great, thanks @rccrdpccl. LGTM -- that was my one suggested change. Now let's get this in! ping @sgerrand
mattnworb
left a comment
There was a problem hiding this comment.
looks good to me overall, and thanks for the contribution. I just have two questions below:
| set +e | ||
| $DOCKER volume ls --filter "dangling=true" -q &> /dev/null | ||
| VOLUMES=$? | ||
| set -e |
There was a problem hiding this comment.
just curious - why do you need to set and unset e here?
There was a problem hiding this comment.
Here we use set and unset e because docker volume was added in docker 1.9, so I wanted the program to stop and fail. (if I recall correctly this project used to use an older version at the time I have started with this feature). It might be not necessary now, as the image of docker-gc is currently build on a newer version....
| EXCLUDE_DEAD=${EXCLUDE_DEAD:=0} | ||
| REMOVE_VOLUMES=${REMOVE_VOLUMES:=0} | ||
| EXCLUDE_VOLUMES_IDS_FILE=${EXCLUDE_VOLUMES_IDS_FILE:=/etc/docker-gc-exclude-volumes} | ||
| VOLUME_DELETE_ONLY_DRIVER=${VOLUME_DELETE_ONLY_DRIVER:=locale} |
There was a problem hiding this comment.
why does this default to locale?
There was a problem hiding this comment.
Oh, good question: it should be local. This was a pretty nasty bug too, because if you would not specify any value for VOLUME_DETE_ONLY_DRIVER it would not actually remove any volume... It is now fixed.
|
any other reason not to merge this one ? |
|
The changes on this MR looks good to me. Would me great to have a maintainer taking a look at it :) |
|
@rccrdpccl could you squash your commits in understandable unit of work please? |
|
@paulRbr I agree with you that messages should have been cleaned up, however this is not my private tree anymore. I would rather squash it on merge: although there are a few messages, I think this feature is small enough to be collapsed to one single commit. What do you think? |
|
@rccrdpccl yes one single commit seems reasonable 👍 |
|
when this PR will be merged ? |
|
is there an update on the status of this? would like to see it! |
|
Thanks, @rccrdpccl. Sorry for the delay. |
Sorry if I did not ask about this feature before doing the PR, but we are using this feature to extend docker-gc so I had to write it anyway.