-
Notifications
You must be signed in to change notification settings - Fork 18.9k
Description
Original discussion in #36295
Currently ImageDelete will untag references as long as there remains at least 1 reference to the image id, even if that reference is used by a container or service. It refuses to untag a reference if there is at least one container using the image id referenced by the tag, even if that tag is not used by any container or service.
I propose the behaviour should be changed so that ImageDelete will untag of any references that are not being used. Image tags that are referenced can still be removed with force. This behaviour is easier to explain and is more intuitive.
An example of the unexpected behaviour:
$ docker pull redis:alpine
...
$ docker tag redis:alpine myimage:1
$ docker run -d myimage:1
552ae8f1134235f9c7d41ec220c9978cb51fd387d4a2d2cd4215b108950ee7c1
$ docker container ls --format '{{.Image}}'
myimage:1
$ docker image rm myimage:1
Untagged: myimage:1
$ docker image rm redis:alpine
Error response from daemon: conflict: unable to remove repository reference "redis:alpine" (must force) - container 20c7d341f7f5 is using its referenced image d3117424aaee
$ docker container ls --format '{{.Image}}'
d3117424aaee
ImageDelete allows myimage:1 to be removed (even through it is referenced), but doesn't allow me to remove (unless forced) redis:alpine which is not referenced by any containers.