{"action":"created","issue":{"url":"https://api.github.com/repos/docker/docker/issues/8926","labels_url":"https://api.github.com/repos/docker/docker/issues/8926/labels{/name}","comments_url":"https://api.github.com/repos/docker/docker/issues/8926/comments","events_url":"https://api.github.com/repos/docker/docker/issues/8926/events","html_url":"https://github.com/docker/docker/issues/8926","id":47602288,"number":8926,"title":"Docker rmi with dangling=true unsafe while images are being pulled","user":{"login":"icksa","id":1550956,"avatar_url":"https://avatars.githubusercontent.com/u/1550956?v=3","gravatar_id":"","url":"https://api.github.com/users/icksa","html_url":"https://github.com/icksa","followers_url":"https://api.github.com/users/icksa/followers","following_url":"https://api.github.com/users/icksa/following{/other_user}","gists_url":"https://api.github.com/users/icksa/gists{/gist_id}","starred_url":"https://api.github.com/users/icksa/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/icksa/subscriptions","organizations_url":"https://api.github.com/users/icksa/orgs","repos_url":"https://api.github.com/users/icksa/repos","events_url":"https://api.github.com/users/icksa/events{/privacy}","received_events_url":"https://api.github.com/users/icksa/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/docker/docker/labels/exp/expert","name":"exp/expert","color":"3B8686"},{"url":"https://api.github.com/repos/docker/docker/labels/kind/bug","name":"kind/bug","color":"FF8C94"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":6,"created_at":"2014-11-03T14:58:16Z","updated_at":"2015-03-26T01:48:13Z","closed_at":null,"body":"I was reading the docker documentation (https://docs.docker.com/reference/commandline/cli/), and noticed the following recommendation for batch clean up of dangling images:\r\n\r\n```\r\nsudo docker rmi $(sudo docker images -f \"dangling=true\" -q)\r\n```\r\n\r\nI was excited when I saw the dangling=true filter since having large numbers of dangling images was creating problems in our build environment. However, I believe this command is unsafe while pulling images since there there are brief points while images are being pulled when docker considers them dangling. To test this, I ran a script which simply pulls 10 images from our private registry, one after another. While this was running I ran the following command in a separate terminal:\r\n\r\n```\r\nwhile true; do docker rmi $(docker images -q -f \"dangling=true\"); sleep 1; done\r\n```\r\n\r\nI noticed that during the pull process, images were being occasionally deleted. Assuming the pull was successful, I will sometimes tag the image from `<private_registry>/<name>` to just `<name>`. After the end of the pull, all images are listed when I run `docker images`, however when I try to run an affected image, I see something like this:\r\n\r\n```\r\nstack@bc03:~$ docker run -ti cassandra\r\nUnable to find image 'cassandra' locally\r\nPulling repository cassandra\r\n2014/11/03 08:36:01 Error: image library/cassandra not found\r\n```\r\n\r\nThe image cannot be found since it was retagged to remove the `<private_registry>` part of the name. My hope was that I could run this command automatically every day to clean up any dangling images, but that is not possible since I may accidentally destroy images that are being pulled.\r\n\r\nI believe that the dangling=true filter should not show images or components of images that are in the process of being pulled...\r\n"},"comment":{"url":"https://api.github.com/repos/docker/docker/issues/comments/86290981","html_url":"https://github.com/docker/docker/issues/8926#issuecomment-86290981","issue_url":"https://api.github.com/repos/docker/docker/issues/8926","id":86290981,"user":{"login":"Mashimiao","id":4852224,"avatar_url":"https://avatars.githubusercontent.com/u/4852224?v=3","gravatar_id":"","url":"https://api.github.com/users/Mashimiao","html_url":"https://github.com/Mashimiao","followers_url":"https://api.github.com/users/Mashimiao/followers","following_url":"https://api.github.com/users/Mashimiao/following{/other_user}","gists_url":"https://api.github.com/users/Mashimiao/gists{/gist_id}","starred_url":"https://api.github.com/users/Mashimiao/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Mashimiao/subscriptions","organizations_url":"https://api.github.com/users/Mashimiao/orgs","repos_url":"https://api.github.com/users/Mashimiao/repos","events_url":"https://api.github.com/users/Mashimiao/events{/privacy}","received_events_url":"https://api.github.com/users/Mashimiao/received_events","type":"User","site_admin":false},"created_at":"2015-03-26T01:48:13Z","updated_at":"2015-03-26T01:48:13Z","body":"Hello,\r\nI have sent a PR #11784 trying to fix this issue"}}