{"action":"created","issue":{"url":"https://api.github.com/repos/spotify/docker-gc/issues/83","labels_url":"https://api.github.com/repos/spotify/docker-gc/issues/83/labels{/name}","comments_url":"https://api.github.com/repos/spotify/docker-gc/issues/83/comments","events_url":"https://api.github.com/repos/spotify/docker-gc/issues/83/events","html_url":"https://github.com/spotify/docker-gc/issues/83","id":129093620,"number":83,"title":"Allow passing \"EXCLUDE_CONTAINERS\" and \"EXCLUDE_IMAGES\" as environmental vars","user":{"login":"emmetog","id":1182891,"avatar_url":"https://avatars.githubusercontent.com/u/1182891?v=3","gravatar_id":"","url":"https://api.github.com/users/emmetog","html_url":"https://github.com/emmetog","followers_url":"https://api.github.com/users/emmetog/followers","following_url":"https://api.github.com/users/emmetog/following{/other_user}","gists_url":"https://api.github.com/users/emmetog/gists{/gist_id}","starred_url":"https://api.github.com/users/emmetog/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/emmetog/subscriptions","organizations_url":"https://api.github.com/users/emmetog/orgs","repos_url":"https://api.github.com/users/emmetog/repos","events_url":"https://api.github.com/users/emmetog/events{/privacy}","received_events_url":"https://api.github.com/users/emmetog/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2016-01-27T10:09:04Z","updated_at":"2016-01-27T18:19:15Z","closed_at":null,"body":"Background\r\n--------------\r\n\r\nRight now to set images and containers to exclude from the cleanup we need to:\r\n1) Write the lists to files\r\n2) Map the files into the docker-gc container\r\n\r\nFar simpler to allow environmental variables which contain a comma separated list of the containers or images.\r\n\r\nHaving to put the excluded images and containers into files and then map the volume complicates things a lot in some cases, here's an example: Jenkins (which is dockerized but has control over the hosts docker server by mounting the docker socket as a volume) runs the docker-gc regularly. In order to specify the containers and images to exclude, Jenkins needs to first put the files on the host (which requires additional volumes mounted into Jenkins) and then map those same files into the docker gc container. If we could pass in the excluded images and containers as environmental variables when the docker gc container is run it would be much simpler.\r\n\r\nThe proposal\r\n--------------\r\n\r\nThis proposal is for two new environmental variables called `EXCLUDE_CONTAINERS` and `EXCLUDE_IMAGES`. They would be used as follows (example):\r\n```\r\n$ docker run --rm -v /var/run/docker.sock:/var/run/docker.sock -e EXCLUDE_CONTAINERS=container-one,container-two -e EXCLUDE_IMAGES=image-one,image-two spotify/docker-gc\r\n```\r\n\r\nFunctionality\r\n--------------\r\n\r\nThe functionality would be:\r\nExcluded containers:\r\n* If the EXCLUDE_CONTAINERS environmental variable is set then it takes priority, if the `/etc/docker-gc-exclude-containers` file exists it is ignored.\r\n* If no EXCLUDE_CONTAINERS environmental variable is set then the behaviour is the same as right now; we check the `/etc/docker-gc-exclude-containers` file and get the excluded containers from there (or exclude no containers if the file doesn't exist).\r\n\r\nExcluded images:\r\n* If the EXCLUDE_IMAGES environmental variable is set then it takes priority, if the `/etc/docker-gc-exclude` file exists it is ignored.\r\n* If no EXCLUDE_IMAGES environmental variable is set then the behaviour is the same as right now; we check the `/etc/docker-gc-exclude` file and get the excluded images from there (or exclude no images if the file doesn't exist).\r\n"},"comment":{"url":"https://api.github.com/repos/spotify/docker-gc/issues/comments/175780143","html_url":"https://github.com/spotify/docker-gc/issues/83#issuecomment-175780143","issue_url":"https://api.github.com/repos/spotify/docker-gc/issues/83","id":175780143,"user":{"login":"emmetog","id":1182891,"avatar_url":"https://avatars.githubusercontent.com/u/1182891?v=3","gravatar_id":"","url":"https://api.github.com/users/emmetog","html_url":"https://github.com/emmetog","followers_url":"https://api.github.com/users/emmetog/followers","following_url":"https://api.github.com/users/emmetog/following{/other_user}","gists_url":"https://api.github.com/users/emmetog/gists{/gist_id}","starred_url":"https://api.github.com/users/emmetog/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/emmetog/subscriptions","organizations_url":"https://api.github.com/users/emmetog/orgs","repos_url":"https://api.github.com/users/emmetog/repos","events_url":"https://api.github.com/users/emmetog/events{/privacy}","received_events_url":"https://api.github.com/users/emmetog/received_events","type":"User","site_admin":false},"created_at":"2016-01-27T18:19:15Z","updated_at":"2016-01-27T18:19:15Z","body":"Hi @mattnworb, I'm not sure I understand your comment.\r\n> I can't see any reason why the \"exclude container/image\" logic couldn't be extended to give priority to an environment file before reading from the file (whose path can be overridden with an existing environment file already)\r\n\r\nWhen you say \"environment file\" you mean an environment variable, right? Just in case there's a misunderstanding, I'm proposing environment variables, not files."}}