ERROR: failed to build: failed to solve: alpine:3.99: failed to resolve source metadata for docker.io/library/alpine:3.99: docker.io/library/alpine:3.99: not found
came from a FROM line whose tag does not exist on Docker Hub. Change the tag to
one the registry has; in the test alpine:latest built.
In the test FROM alpine:3.99 failed and FROM alpine:latest built.
In these two failing runs the end of the message told them apart: the missing tag ended in
not found, a misspelled image name in pull access denied.
The error
foreach ($d in 'badtag','twoargs','empty','comments') { Set-Location "$lab\$d"; Write-Output "=== [$d] cmd> docker build --progress=plain -t fix12-dkbuild-$d . 2>&1"; cmd /c "docker build --progress=plain -t fix12-dkbuild-$d . 2>&1"; Write-Output "exit=$LASTEXITCODE" }
=== [badtag] cmd> docker build --progress=plain -t fix12-dkbuild-badtag . 2>&1
#0 building with "desktop-linux" instance using docker driver
#1 [internal] load build definition from Dockerfile
#1 transferring dockerfile: 65B 0.0s done
#1 DONE 0.1s
#2 [internal] load metadata for docker.io/library/alpine:3.99
#2 ERROR: docker.io/library/alpine:3.99: not found
------
> [internal] load metadata for docker.io/library/alpine:3.99:
------
Dockerfile:1
--------------------
1 | >>> FROM alpine:3.99
2 | CMD ["sh"]
3 |
--------------------
ERROR: failed to build: failed to solve: alpine:3.99: failed to resolve source metadata for docker.io/library/alpine:3.99: docker.io/library/alpine:3.99: not found
exit=1
...
The first line is the PowerShell loop that ran; it built four test folders, and the cut at the end is the output for the other three.
Why it happens
The build failed while looking up the base image named on FROM, before any
instruction ran. That is step #2,
load metadata for docker.io/library/alpine:3.99, and it is the step that
failed. The short name alpine was printed as
docker.io/library/alpine, a name on Docker Hub, and the lookup for the tag
3.99 came back not found. The build then printed the Dockerfile
with >>> on line 1, the FROM line, and stopped.
A misspelled image name ended differently. FROM alpne:latest failed in the same
step with failed to resolve source metadata for docker.io/library/alpne:latest: pull
access denied, repository does not exist or may require authorization: server message:
insufficient_scope: authorization failed (did you mean alpine:latest?). So in these
two runs not found pointed at the tag, and pull access denied at
the name.
The fix
FROM alpine:latest
CMD ["sh"]
foreach ($d in 'badtagfix','twoargsfix','commentsfix') { Set-Location "$lab\$d"; Write-Output "=== [$d] cmd> docker build --progress=plain -t fix12-dkbuild-$d . 2>&1"; cmd /c "docker build --progress=plain -t fix12-dkbuild-$d . 2>&1" | Select-Object -Last 4; Write-Output "exit=$LASTEXITCODE" }
=== [badtagfix] cmd> docker build --progress=plain -t fix12-dkbuild-badtagfix . 2>&1
#5 exporting manifest list sha256:8fef1ef73e80e57b4baf04c363ff9b0a9d1092b66c1965c4d15bd304768d8689 0.0s done
#5 naming to docker.io/library/fix12-dkbuild-badtagfix:latest done
#5 unpacking to docker.io/library/fix12-dkbuild-badtagfix:latest 0.0s done
#5 DONE 0.2s
exit=0
...
The file above is the whole fixed Dockerfile; only the tag changed. This loop kept the last
four lines of each build (Select-Object -Last 4), and the cut at the end is the
output for the other two folders. For a build you want to repeat, a version tag that exists
is the alternative to latest; none was tried here.
How it was reproduced
A two-line Dockerfile with FROM alpine:3.99, built on Docker Desktop 4.99.0 for
Windows with client and engine 29.9.3 and buildx v0.38.1. The two failing builds (the
missing tag and the misspelled name) each made one anonymous, read-only lookup on Docker
Hub; the fix used the cached alpine:latest (image id 294b683cb724). Commands
ran in cmd, started from PowerShell as cmd /c "... 2>&1",
with the exit code printed after each by Write-Output "exit=$LASTEXITCODE";
$lab is the test's scratch folder. The folders lab\badtag,
lab\badname and lab\badtagfix and the image tags
fix12-dkbuild-badtag, -badname and -badtagfix are the
test's own.
Frequently asked
- What does 'failed to resolve source metadata' mean in docker build?
- The build could not look up the image on the FROM line. In the test the message ended in not found for alpine:3.99, a tag that does not exist on the registry.
- How do I fix 'not found' for the FROM image in a Dockerfile?
- Use a tag that exists. In the test FROM alpine:3.99 failed and FROM alpine:latest built with exit code 0.
- Why does docker build say docker.io/library when I wrote only alpine?
- The build log names the image in full. In the test FROM alpine:3.99 appeared as docker.io/library/alpine:3.99, the Docker Hub name, in the failing step.
More decoded errors in the Fixes category. The same
missing tag from docker pull or docker run is in
failed to resolve reference ... not found.