Repository navigation
Description
Description
This report is a follow-up to the discussion I opened here
The command nerdctl image ls myapp, where myapp is repository only, does not find any images of myapp if there is no latest tag present for myapp. This behaviour is very different to one of the Docker client, e.g. docker image ls java. I suspect it is an unexpected behaviour or even a bug.
The current behaviour is due to the unconditional use of TagNameOnly which adds the default tag "latest" to a reference if it only has a repo name, from here:
- The
referenceutil.Parse("myapp")yieldsdocker.io/library/myappdue tonerdctl/pkg/referenceutil/referenceutil.go
Lines 133 to 134 in 9145d0f
if tg, ok := ir.nn.(reference.Named); ok { ir.nn = reference.TagNameOnly(tg) - The
TagNameOnlyunconditionally appends:latestin https://github.com/distribution/reference/blob/0965666a6ade2e06035fe352e38344be1e68951a/normalize.go#L248-L252 - The filter becomes
name==docker.io/library/myapp:latest
It's possible that this implementation of the listOptions function:
nerdctl/cmd/nerdctl/image/image_list.go
Lines 80 to 84 in 9145d0f
| parsedReference, err := referenceutil.Parse(args[0]) | |
| if err != nil { | |
| return nil, err | |
| } | |
| filters = []string{fmt.Sprintf("name==%s", parsedReference)} |
should be modified to something like this:
- filters = []string{fmt.Sprintf("name==%s", parsedReference)}
+ if parsedReference.ExplicitTag != "" || parsedReference.Digest != (digest.Digest("")) {
+ filters = []string{fmt.Sprintf("name==%s", parsedReference)}
+ } else {
+ filters = []string{fmt.Sprintf("name~=^%s:", regexp.QuoteMeta(parsedReference.Name()))}
+ }To work around the inconvenience of the current implementation users instead of the simple invocation of
nerdctl image ls myapp
have to apply the filter trick
nerdctl image ls --filter 'reference=myapp:*'
Steps to reproduce the issue
- Go to nerdctl image ls only lists images with tag latest #5110
- Follow the sequence of examples presented there
Describe the results you received and expected
Received results:
PS > nerdctl image ls myapp
REPOSITORY TAG IMAGE ID CREATED PLATFORM SIZE BLOB SIZE
Expected results:
PS > nerdctl image ls myapp
REPOSITORY TAG IMAGE ID CREATED PLATFORM SIZE BLOB SIZE
myapp 9.8-ltsc2022-0.1.0-dev.5011fb1 5e2b4a9d1b07 34 minutes ago windows/amd64 11.91GB 2.113GB
What version of nerdctl are you using?
PS > nerdctl version
time="2026-07-30T21:53:56+01:00" level=warning msg="unable to determine runc version" error="exec: \"runc\": executable file not found in %PATH%"
Client:
Version: v2.3.4
OS/Arch: windows/amd64
Git commit: 0ce88b9d78b13f0caebc59c6bb01885d7df24fba
buildctl:
Version: v0.31.2
GitCommit: e42e1bfd389af7203238cce77b1f7dad447285e9
Server:
containerd:
Version: v2.3.3
GitCommit: aad11006b869517fcd3009450b6f82da282e1a9b
runc:
Version:
Are you using a variant of nerdctl? (e.g., Rancher Desktop)
None
Host information
Windows Server 2022 with containerd, buildkit and nerdctl
Activity
fix: image ls with a bare repository name should match all tags