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

docker images ls --digests provides different output if tag provided or not #43830

Open
nobletrout opened this issue Jul 18, 2022 · 3 comments · May be fixed by #43895 or #43948
Open

docker images ls --digests provides different output if tag provided or not #43830

nobletrout opened this issue Jul 18, 2022 · 3 comments · May be fixed by #43895 or #43948
Labels
kind/bug Bugs are bugs. The cause may or may not be known at triage time so debugging may be needed. version/20.10 version/23.0

Comments

@nobletrout
Copy link

nobletrout commented Jul 18, 2022

Description

docker image ls --digests $image vs. docker image ls --digests $image:$tag provides different output.

Notably digest column is blank if a tag is provided.

Reproduce

$docker pull library/debian:bullseye-slim
bullseye-slim: Pulling from library/debian
461246efe0a7: Pull complete
Digest: sha256:f576b8067b77ff85c70725c976b7b6cde960898e2f19b9abab3fb148407614e2
Status: Downloaded newer image for debian:bullseye-slim
docker.io/library/debian:bullseye-slim
$docker image ls --digests debian
REPOSITORY   TAG             DIGEST                                                                    IMAGE ID       CREATED      SIZE
debian       bullseye-slim   sha256:f576b8067b77ff85c70725c976b7b6cde960898e2f19b9abab3fb148407614e2   f8f4b4b67518   6 days ago   80.4MB
$docker image ls --digests debian:bullseye-slim
REPOSITORY   TAG             DIGEST    IMAGE ID       CREATED      SIZE
debian       bullseye-slim   <none>    f8f4b4b67518   6 days ago   80.4MB
$

Expected behavior

docker image ls --digests debian:bullseye-slim should provide the digest information.

docker version

Client: Docker Engine - Community
 Version:           20.10.17
 API version:       1.41
 Go version:        go1.18.3
 Git commit:        100c70180f
 Built:             Mon Jun  6 21:36:39 2022
 OS/Arch:           darwin/amd64
 Context:           colima
 Experimental:      true

Server:
 Engine:
  Version:          20.10.14
  API version:      1.41 (minimum version 1.12)
  Go version:       go1.17.9
  Git commit:       87a90dc786bda134c9eb02adbae2c6a7342fb7f6
  Built:            Fri Apr 15 00:05:05 2022
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          v1.5.11
  GitCommit:        3df54a852345ae127d1fa3092b95168e4a88e2f8
 runc:
  Version:          1.0.2
  GitCommit:        52b36a2dd837e8462de8e01458bf02cf9eea47dd
 docker-init:
  Version:          0.19.0
  GitCommit:        

docker info

Client:
 Context:    colima
 Debug Mode: false

Server:
 Containers: 0
  Running: 0
  Paused: 0
  Stopped: 0
 Images: 33
 Server Version: 20.10.14
 Storage Driver: overlay2
  Backing Filesystem: extfs
  Supports d_type: true
  Native Overlay Diff: true
  userxattr: false
 Logging Driver: json-file
 Cgroup Driver: cgroupfs
 Cgroup Version: 1
 Plugins:
  Volume: local
  Network: bridge host ipvlan macvlan null overlay
  Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
 Swarm: inactive
 Runtimes: io.containerd.runc.v2 io.containerd.runtime.v1.linux runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: 3df54a852345ae127d1fa3092b95168e4a88e2f8
 runc version: 52b36a2dd837e8462de8e01458bf02cf9eea47dd
 init version: 
 Security Options:
  seccomp
   Profile: default
 Kernel Version: 5.15.37-0-virt
 Operating System: Alpine Linux v3.15
 OSType: linux
 Architecture: x86_64
 CPUs: 4
 Total Memory: 7.771GiB
 Name: colima
 ID: CVI6:H5XH:4DKY:ETBA:VF3P:DZPZ:JLZV:SZBY:7ZUY:AZJP:ZZV2:KFLT
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 Registry: https://index.docker.io/v1/
 Labels:
 Experimental: false
 Insecure Registries:
  127.0.0.0/8
 Live Restore Enabled: false

Additional Info

No response

@nobletrout nobletrout added kind/bug Bugs are bugs. The cause may or may not be known at triage time so debugging may be needed. status/0-triage labels Jul 18, 2022
@corhere
Copy link
Contributor

corhere commented Jul 25, 2022

I can reproduce this with v22.06.0-beta.0-200-g98d8343aa2

@jimlinntu
Copy link
Contributor

jimlinntu commented Jul 30, 2022

From what I've dug into so far, I think the issue probably results from

if _, ok := ref.(reference.Canonical); ok {
summary.RepoDigests = append(summary.RepoDigests, reference.FamiliarString(ref))
}

The output from docker/cli

root@docker-cli-dev$ docker image ls --digests nginx
RepoTags: [nginx:1.19.6-alpine]
RepoDigests: [nginx@sha256:c2ce58e024275728b00a554ac25628af25c54782865b3487b11c21cafb7fabda]
REPOSITORY   TAG             DIGEST                                                                    IMAGE ID       CREATED         SIZE
nginx        1.19.6-alpine   sha256:c2ce58e024275728b00a554ac25628af25c54782865b3487b11c21cafb7fabda   629df02b47c8   19 months ago   22.3MB
root@docker-cli-dev$ docker image ls --digests nginx:1.19.6-alpine
RepoTags: [nginx:1.19.6-alpine]
RepoDigests: []
REPOSITORY   TAG             DIGEST    IMAGE ID       CREATED         SIZE
nginx        1.19.6-alpine   <none>    629df02b47c8   19 months ago   22.3MB

@jimlinntu
Copy link
Contributor

I think this part:

for _, ref := range i.referenceStore.References(id.Digest()) {
if opts.Filters.Contains("reference") {
var found bool
var matchErr error
for _, pattern := range opts.Filters.Get("reference") {
found, matchErr = reference.FamiliarMatch(pattern, ref)
if matchErr != nil {
return nil, matchErr
}
if found {
break
}
}
if !found {
continue
}
}
if _, ok := ref.(reference.Canonical); ok {
summary.RepoDigests = append(summary.RepoDigests, reference.FamiliarString(ref))
}
if _, ok := ref.(reference.NamedTagged); ok {
summary.RepoTags = append(summary.RepoTags, reference.FamiliarString(ref))
}
}

Should standardize pattern first (ex. debian:tag -> debian) because this part is searching for RepoDigests and RepoTags

@jimlinntu jimlinntu linked a pull request Aug 1, 2022 that will close this issue
corhere added a commit to corhere/moby that referenced this issue Aug 10, 2022
The List Images API endpoint's `filters` parameter can be a bit quirky.
Unlike most of the filter predicates, which are applied by including or
excluding each image from the list, the `reference` predicate filters
out individual references from the image summary's `RepoTags` and
`RepoDigests` fields. This behaviour is surprising to our users as they
cannot use the API to look up the repo digests for a specified image tag
(or vice versa) without widening the filter to match on only the
repository and post-filtering the results. Change the API such that the
filters are only used to determine whether or not to include a
particular image in the list of image summaries, without filtering the
contents of the summary.

Fixes moby#43830

Signed-off-by: Cory Snider <csnider@mirantis.com>
@corhere corhere linked a pull request Aug 10, 2022 that will close this issue
corhere added a commit to corhere/moby that referenced this issue Aug 10, 2022
The List Images API endpoint's `filters` parameter can be a bit quirky.
Unlike most of the filter predicates, which are applied by including or
excluding each image from the list, the `reference` predicate filters
out individual references from the image summary's `RepoTags` and
`RepoDigests` fields. This behaviour is surprising to our users as they
cannot use the API to look up the repo digests for a specified image tag
(or vice versa) without widening the filter to match on only the
repository and post-filtering the results. Change the API such that the
filters are only used to determine whether or not to include a
particular image in the list of image summaries, without filtering the
contents of the summary.

Fixes moby#43830

Signed-off-by: Cory Snider <csnider@mirantis.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Bugs are bugs. The cause may or may not be known at triage time so debugging may be needed. version/20.10 version/23.0
Projects
None yet
4 participants
@corhere @nobletrout @jimlinntu and others