Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RFD: allow parent images to be removed (with --force) #30722

Open
thaJeztah opened this issue Feb 3, 2017 · 3 comments
Open

RFD: allow parent images to be removed (with --force) #30722

thaJeztah opened this issue Feb 3, 2017 · 3 comments
Labels
area/builder area/images kind/enhancement Enhancements are not bugs or new features but can improve usability or performance.

Comments

@thaJeztah
Copy link
Member

thaJeztah commented Feb 3, 2017

For historical reasons, the local image store still has code in place to disallow removing "parent" images.

For example;

$ DOCKER_BUILDKIT=0 docker build -t parent -<<EOF
FROM scratch
LABEL foo=bar
EOF

$ DOCKER_BUILDKIT=0 docker build -t child -<<EOF
FROM parent:latest
LABEL foo=baz
EOF


$ docker images ls --filter reference=parent
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
parent              latest              17789f62da6c        About an hour ago   0 B

$ docker image rm 17789f62da6c
Error response from daemon: conflict: unable to delete 17789f62da6c (cannot be forced) - image has dependent child images

Since the introduction of the content-addressable store, the "child/parent" chain
is only used for the local build cache, but is not required to run an image.

I think we should allow removing the parent image if --force is used.

Note that removing the parent image will not cleanup any disk space (because
the layers are still used by the child image), however it does allow users
to clean up images they no longer need.

related discussion #25602

/cc @tonistiigi @dmcgowan

@thaJeztah thaJeztah added area/images kind/enhancement Enhancements are not bugs or new features but can improve usability or performance. labels Feb 3, 2017
@tonistiigi
Copy link
Member

Would we remove the whole parent chain up to that deleted image then? That may be bit unexpected but if we don't do it then every deletion possibly creates a new dangling image.

@thaJeztah
Copy link
Member Author

Good point, I think for any direct descendant of that image, that would be the case yes

@thaJeztah
Copy link
Member Author

thaJeztah commented Jul 27, 2020

Looks like this already works if buildkit is enabled, so only an issue if images are built with the classic builder (edited the example steps to use DOCKER_BUILDKIT=0

BuildKit doesn't set the "Parent" chain;

When built with DOCKER_BUILDKIT=1:

docker inspect --format '{{json .Parent}}' child
""

When built with DOCKER_BUILDKIT=0:

docker inspect --format '{{json .Parent}}' child
"sha256:9adebf3f78911d6050aff78e1bf2815c9beabea4fea0848b3ed77679fdefeb94"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/builder area/images kind/enhancement Enhancements are not bugs or new features but can improve usability or performance.
Projects
None yet
Development

No branches or pull requests

3 participants