Skip to content

[24.0 backport] c8d/prune: Fix images being deleted when they're still used with a different reference#45857

Merged
thaJeztah merged 7 commits intomoby:24.0from
neersighted:backport/45839/24.0
Jun 30, 2023
Merged

[24.0 backport] c8d/prune: Fix images being deleted when they're still used with a different reference#45857
thaJeztah merged 7 commits intomoby:24.0from
neersighted:backport/45839/24.0

Conversation

@neersighted
Copy link
Copy Markdown
Member

@neersighted neersighted commented Jun 30, 2023

Warning
Slight conflicts due to a lack of:


- What I did
Fixed image prune -a deleting dangling images used by containers.

- How I did it

  • Exclude dangling tag of the images used by containers (this makes sure that if the original image was deleted we don't delete the dangling image)
  • Exclude images that are used by containers which were started by specifying an image ID instead of a specific name.

- How to verify it

$ make TEST_INTEGRATION_USE_SNAPSHOTTER=1 \
       DOCKER_GRAPHDRIVER=overlayfs \
       TEST_FILTER=TestPruneDontDeleteUsedDangling \
       test-integration
...
INFO: Testing against a local daemon
=== RUN   TestPruneDontDeleteUsedDangling
--- PASS: TestPruneDontDeleteUsedDangling (0.07s)
PASS

DONE 1 tests in 1.079s

- Description for the changelog

containerd integration: `docker image prune -a` no longer removes images still in use by running containers

- A picture of a cute animal (not mandatory but encouraged)

thaJeztah and others added 7 commits June 30, 2023 10:31
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
(cherry picked from commit df5deab)
Signed-off-by: Bjorn Neergaard <bjorn.neergaard@docker.com>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
(cherry picked from commit f17c9e4)
Signed-off-by: Bjorn Neergaard <bjorn.neergaard@docker.com>
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
(cherry picked from commit a96e604)
Signed-off-by: Bjorn Neergaard <bjorn.neergaard@docker.com>
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
(cherry picked from commit 2b0655a)
Signed-off-by: Bjorn Neergaard <bjorn.neergaard@docker.com>
So we don't override the original Labels in the passed image object.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
(cherry picked from commit a6d5db3)
Signed-off-by: Bjorn Neergaard <bjorn.neergaard@docker.com>
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
(cherry picked from commit a93298d)
Signed-off-by: Bjorn Neergaard <bjorn.neergaard@docker.com>
If an image is only by id instead of its name, don't prune it
completely. but only untag it and create a dangling image for it.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
(cherry picked from commit e638351)
Resolved conflicts:
	daemon/containerd/image_prune.go
Signed-off-by: Bjorn Neergaard <bjorn.neergaard@docker.com>
Copy link
Copy Markdown
Member

@thaJeztah thaJeztah left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@thaJeztah thaJeztah merged commit 3bd0f58 into moby:24.0 Jun 30, 2023
@neersighted neersighted deleted the backport/45839/24.0 branch June 30, 2023 19:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/images Image Distribution containerd-integration Issues and PRs related to containerd integration kind/bugfix PR's that fix bugs status/4-merge

Projects

Development

Successfully merging this pull request may close these issues.

3 participants