{"action":"created","issue":{"url":"https://api.github.com/repos/docker/docker/issues/18873","labels_url":"https://api.github.com/repos/docker/docker/issues/18873/labels{/name}","comments_url":"https://api.github.com/repos/docker/docker/issues/18873/comments","events_url":"https://api.github.com/repos/docker/docker/issues/18873/events","html_url":"https://github.com/docker/docker/issues/18873","id":123654054,"number":18873,"title":"`docker rmi ID` untags image even if there is a running container that is using it","user":{"login":"rindek","id":881209,"avatar_url":"https://avatars.githubusercontent.com/u/881209?v=3","gravatar_id":"","url":"https://api.github.com/users/rindek","html_url":"https://github.com/rindek","followers_url":"https://api.github.com/users/rindek/followers","following_url":"https://api.github.com/users/rindek/following{/other_user}","gists_url":"https://api.github.com/users/rindek/gists{/gist_id}","starred_url":"https://api.github.com/users/rindek/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rindek/subscriptions","organizations_url":"https://api.github.com/users/rindek/orgs","repos_url":"https://api.github.com/users/rindek/repos","events_url":"https://api.github.com/users/rindek/events{/privacy}","received_events_url":"https://api.github.com/users/rindek/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2015-12-23T12:42:23Z","updated_at":"2015-12-24T11:28:54Z","closed_at":null,"body":"## Description of problem:\r\n\r\n1. Using `docker rmi` with ID as argument untags image even if there is a running container that is used by this image\r\n2. As result it marks that image as dangling\r\n\r\n## docker version:\r\n\r\n```\r\nClient:\r\n Version:      1.9.1\r\n API version:  1.21\r\n Go version:   go1.4.2\r\n Git commit:   a34a1d5\r\n Built:        Fri Nov 20 13:06:12 UTC 2015\r\n OS/Arch:      linux/amd64\r\n\r\nServer:\r\n Version:      1.9.1\r\n API version:  1.21\r\n Go version:   go1.4.2\r\n Git commit:   a34a1d5\r\n Built:        Fri Nov 20 13:06:12 UTC 2015\r\n OS/Arch:      linux/amd64\r\n```\r\n\r\n## docker info:\r\n\r\n```\r\nContainers: 5\r\nImages: 47\r\nServer Version: 1.9.1\r\nStorage Driver: aufs\r\n Root Dir: /var/lib/docker/aufs\r\n Backing Filesystem: extfs\r\n Dirs: 57\r\n Dirperm1 Supported: true\r\nExecution Driver: native-0.2\r\nLogging Driver: json-file\r\nKernel Version: 3.16.0-0.bpo.4-amd64\r\nOperating System: Debian GNU/Linux 7 (wheezy)\r\nCPUs: 8\r\nTotal Memory: 31.35 GiB\r\nName: [... cut ...]\r\nID: BHQB:3N5X:46IT:BLJI:QQOA:IYVH:4H3K:CV57:VTT3:5S5W:U3NC:OJRK\r\nWARNING: No memory limit support\r\nWARNING: No swap limit support\r\n```\r\n\r\n## uname -a\r\n\r\n```\r\nLinux hostname 3.16.0-0.bpo.4-amd64 #1 SMP Debian 3.16.7-ckt11-1~bpo70+1 (2015-06-08) x86_64 GNU/Linux\r\n```\r\n\r\n## Steps to reproduce\r\n\r\n1. run any container, ex: `docker run -it busybox`\r\n2. run `docker rmi IMAGE_ID`\r\n\r\n## Actual Results:\r\n\r\n`docker images`:\r\n\r\n```\r\n$ docker images\r\nREPOSITORY          TAG                 IMAGE ID            CREATED             VIRTUAL SIZE\r\n<none>              <none>              ac6a7980c6c2        2 weeks ago         1.113 MB\r\n```\r\n\r\n`docker ps`:\r\n\r\n```\r\n$ docker ps\r\nCONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                      NAMES\r\n3b46060d3c2f        ac6a7980c6c2        \"sh\"                     3 minutes ago       Up 3 minutes                                   trusting_raman\r\n```\r\n\r\n\r\n## Expected Results:\r\n\r\n`docker images`:\r\n\r\n```\r\n$ docker images\r\nREPOSITORY          TAG                 IMAGE ID            CREATED             VIRTUAL SIZE\r\nbusybox             latest              ac6a7980c6c2        2 weeks ago         1.113 MB\r\n```\r\n\r\n`docker ps`:\r\n\r\n```\r\n$ docker ps\r\nCONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                      NAMES\r\n3b46060d3c2f        busybox             \"sh\"                     12 seconds ago      Up 11 seconds                                  trusting_raman\r\n```\r\n\r\nIn my understanding running this command should return and error and do not untag the image.\r\n\r\n## Additional info:\r\n\r\nThe error received while trying to remove the image by id is correct:\r\n\r\n```\r\n$ docker rmi ac6a7980c6c2\r\nError response from daemon: conflict: unable to delete ac6a7980c6c2 (cannot be forced) - image is being used by running container 3b46060d3c2f\r\nError: failed to remove images: [ac6a7980c6c2]\r\n```\r\n\r\nHowever - docker still untags this image making it dangling (which I believe shouldn't happen, because it's still used image) - it can be filtered by `docker images -f dangling=true`:\r\n\r\n```\r\nREPOSITORY          TAG                 IMAGE ID            CREATED             VIRTUAL SIZE\r\n<none>              <none>              ac6a7980c6c2        2 weeks ago         1.113 MB\r\n```\r\n\r\n\r\nThis causes couple issues when cleaning up old non-used images by \"well-known\" script `docker rmi $(docker images -qf)`\r\n\r\nAlso: I found out that this is not happening when:\r\n1. Using rmi with IMAGE_NAME\r\n2. Having same image with multiple tags\r\n"},"comment":{"url":"https://api.github.com/repos/docker/docker/issues/comments/167095855","html_url":"https://github.com/docker/docker/issues/18873#issuecomment-167095855","issue_url":"https://api.github.com/repos/docker/docker/issues/18873","id":167095855,"user":{"login":"thaJeztah","id":1804568,"avatar_url":"https://avatars.githubusercontent.com/u/1804568?v=3","gravatar_id":"","url":"https://api.github.com/users/thaJeztah","html_url":"https://github.com/thaJeztah","followers_url":"https://api.github.com/users/thaJeztah/followers","following_url":"https://api.github.com/users/thaJeztah/following{/other_user}","gists_url":"https://api.github.com/users/thaJeztah/gists{/gist_id}","starred_url":"https://api.github.com/users/thaJeztah/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thaJeztah/subscriptions","organizations_url":"https://api.github.com/users/thaJeztah/orgs","repos_url":"https://api.github.com/users/thaJeztah/repos","events_url":"https://api.github.com/users/thaJeztah/events{/privacy}","received_events_url":"https://api.github.com/users/thaJeztah/received_events","type":"User","site_admin":false},"created_at":"2015-12-24T11:28:54Z","updated_at":"2015-12-24T11:28:54Z","body":"I think there's two things to discuss here wrt behavior;\r\n\r\n- should I be able to *untag* an image if it's still in use? Possibly, yes; the same will also happen if I `docker pull` and a newer version is downloaded. Open to suggestions though\r\n- should it be regarded \"dangling\"? No, because it's still in use\r\n\r\nNote; haven't checked what the behavior on master is"}}