Skip to content

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

@thaJeztah

Description

@thaJeztah

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/builderBuildarea/imagesImage Servicekind/enhancementEnhancements are not bugs or new features but can improve usability or performance.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions