Docker build fails to resolve the openjdk slim-buster base image
failed to resolve source metadata for docker.io/library/openjdk:21-slim-busterShort answer
The tag you named does not exist any more. The openjdk image on Docker Hub is officially deprecated and only lists a few early-access tags, and Debian 10 buster is out of support. Pick a maintained Java image such as eclipse-temurin and a current base, then rebuild.
Fix it fast
1Find out which cause you have
Ask the registry about the exact tag. If it cannot be inspected, the tag is gone and no Docker setting will bring it back.
docker buildx imagetools inspect openjdk:21-slim-buster2Match what you see, then jump to its fix
What does the error look like?
failed to resolve source metadata for docker.io/library/openjdk:21-slim-buster
Cause 1 of 2
The openjdk image is deprecated and has no such tag
1Check
Docker Hub marks openjdk as officially deprecated and says only Early Access tags are still updated. Open its tag list and look for your tag.
docker buildx imagetools inspect openjdk:21-slim2Fix
Change FROM to a maintained Java image. Docker Hub's own notice lists amazoncorretto, eclipse-temurin, ibm-semeru-runtimes, ibmjava and sapmachine.
# before
FROM openjdk:21-slim-buster
# after
FROM eclipse-temurin:213Verify
The base image resolves and the build starts.
docker build -t my-java-app .Confirmed by hub.docker.com
Cause 2 of 2
The tag is built on Debian buster, which is no longer supported
1Check
Debian 10 (buster) got its last security updates under LTS on 30 June 2024, and Debian points users to a newer release.
docker buildx imagetools inspect eclipse-temurin:212Fix
Move to a base image built on a supported release. The eclipse-temurin default image is Ubuntu based, with tags named after the suite, and an -alpine variant is also offered.
FROM eclipse-temurin:21-alpine
# or, for a Debian/Ubuntu-style base:
# FROM eclipse-temurin:213Verify
Run the new image and print the Java version.
docker run --rm eclipse-temurin:21 java -versionConfirmed by debian.org
How do I stop it coming back?
- Avoid base tags that name an old OS release; check the tag list of your base image when you upgrade Java.
- Pin to a major version of a maintained image, and read the deprecation notice on Docker Hub before choosing one.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Projects of mine built on the same technologies:
Related fixes
Servers
docker build stops while loading metadata for the base image
ERROR [internal] load metadata for docker.io/library/node:22
The build could not look up the base image from FROM.
2 causes, each with a fixServers
The Java SDK finds no AWS credentials on an EC2 instance or in a container on it
InstanceProfileCredentialsProvider()
The SDK walks a fixed list of credential sources and the EC2 instance role is the last one.
3 causes, each with a fixServers
docker build stops at COPY because the file is not in the build context
ERROR: failed to solve: failed to compute cache key:
COPY can only read files that are inside the build context, the folder you pass to docker build.
3 causes, each with a fixServers
A Java container dies at start with 'insufficient memory' or errno=12
os::commit_memory failed; error='Not enough space' (errno=12)
The JVM asked the operating system for more memory than the container is allowed to use.
3 causes, each with a fixServers
MongoDB says Authentication failed from a Java app against a Docker container
MongoCommandException: Command failed with error 18 (AuthenticationFailed): 'Authentication failed.' on server localhost:27017
Error 18 means MongoDB found no matching user in the database it checked.
4 causes, each with a fixServers
Testcontainers fails with Could not connect to Ryuk at localhost
docker ps shows a testcontainers/ryuk container while the test fails
Ryuk is the helper container Testcontainers starts to clean up after tests.
3 causes, each with a fix