-
Notifications
You must be signed in to change notification settings - Fork 18.9k
Closed
Labels
area/imagesImage DistributionImage Distributioncontainerd-integrationIssues and PRs related to containerd integrationIssues and PRs related to containerd integrationkind/bugBugs are bugs. The cause may or may not be known at triage time so debugging may be needed.Bugs are bugs. The cause may or may not be known at triage time so debugging may be needed.
Description
Description
docker image prune -a will untag used image when the only container using the image was created from an image specified by ID.
Additionally, when the container is started from a digested reference (like busybox@sha256:abcdef...) prune will not only untag the image, but also delete the image content.
While the first behavior might make sense - it's inconsistent with the graphdrivers implementation.
Reproduce
$ docker pull alpine
$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
alpine latest b89d9c93e9ed 5 days ago 13.6MB
$ docker run -d alpine@sha256:b89d9c93e9ed3597455c90a0b88a8bbb5cb7188438f70953fede212a0c4394e0 sleep infinity
...
$ docker image prune -a
WARNING! This will remove all images without at least one container associated to them.
Are you sure you want to continue? [y/N] y
Deleted Images:
untagged: alpine:latest
deleted: sha256:b89d9c93e9ed3597455c90a0b88a8bbb5cb7188438f70953fede212a0c4394e0
deleted: sha256:647a509e17306d117943c7f91de542d7fb048133f59c72dff7893cffd1836e11
deleted: sha256:092561eea88f9f28654bbade209576f5f93efeb8c7ba66a07ac2033c0ddc8ae7
deleted: sha256:a258b2a6b59a7aa244d8ceab095c7f8df726f27075a69fca7ad8490f3f63148a$ docker pull alpine
$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
alpine latest b89d9c93e9ed 5 days ago 13.6MB
$ docker run -d sha256:b89d9c93e9ed3597455c90a0b88a8bbb5cb7188438f70953fede212a0c4394e0 sleep infinity
...
$ docker image prune -a
WARNING! This will remove all images without at least one container associated to them.
Are you sure you want to continue? [y/N] y
Deleted Images:
untagged: alpine:latestExpected behavior
Prune definitely shouldn't delete content of images used by containers.
Prune probably shouldn't (if we want to be consistent with graphdrivers) untag images if used by containers that were started off the image ID.
docker version
Client:
Version: 27.0.1
API version: 1.46
Go version: go1.21.11
Git commit: 7fafd33
Built: Mon Jun 24 14:56:52 2024
OS/Arch: darwin/arm64
Context: desktop-linux
Server: Docker Desktop 4.33.0 (1)
Engine:
Version: 27.0.1
API version: 1.46 (minimum version 1.24)
Go version: go1.21.11
Git commit: ff1e2c0
Built: Mon Jun 24 14:58:04 2024
OS/Arch: linux/arm64
Experimental: false
containerd:
Version: 1.7.18
GitCommit: ae71819c4f5e67bb4d5ae76a6b735f29cc25774e
runc:
Version: 1.7.18
GitCommit: v1.1.13-0-g58aa920
docker-init:
Version: 0.19.0
GitCommit: de40ad0docker info
containerd integration enabledAdditional Info
No response
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
area/imagesImage DistributionImage Distributioncontainerd-integrationIssues and PRs related to containerd integrationIssues and PRs related to containerd integrationkind/bugBugs are bugs. The cause may or may not be known at triage time so debugging may be needed.Bugs are bugs. The cause may or may not be known at triage time so debugging may be needed.