I’m trying to build a docker image for my java file on my M1 max MacBook, my dockerfile:
FROM openjdk:13
COPY . /src/java
WORKDIR /src/java
RUN ["javac","greenchallenge.java"]
ENTRYPOINT ["java","greenchallenge"]
Steps followed to build the image:
- Created a new builder using:
docker buildx create --name pibuilder
(I wanted to use the multi architecture feature) - Initialed the builder using:
docker buildx use pibuilder
. - Built the image and pushed it using:
docker buildx build --platform linux/amd64,linux/arm64,linux/arm/v7 -t my_java:latest -t my_java:1.0.0 --push .
After running step-3, I got the below log:
[+] Building 19.7s (6/6) FINISHED
=> [internal] booting buildkit 18.6s
=> => pulling image moby/buildkit:buildx-stable-1 18.1s
=> => creating container buildx_buildkit_pibuilder0 0.6s
=> [internal] load .dockerignore 0.0s
=> => transferring context: 2B 0.0s
=> [internal] load build definition from dockerfile 0.0s
=> => transferring dockerfile: 493B 0.0s
=> ERROR [linux/arm64 internal] load metadata for docker.io/library/open 1.0s
=> CANCELED [linux/arm/v7 internal] load metadata for docker.io/library/ 1.0s
=> ERROR [linux/amd64 internal] load metadata for docker.io/library/open 1.0s
------
> [linux/arm64 internal] load metadata for docker.io/library/openjdk:13:
------
------
> [linux/amd64 internal] load metadata for docker.io/library/openjdk:13:
------
dockerfile:1
--------------------
1 | >>> FROM openjdk:13
2 | COPY . /src/java
3 | WORKDIR /src/java
--------------------
error: failed to solve: openjdk:13: failed to do request: Head "https://registry-1.docker.io/v2/library/openjdk/manifests/13": x509: certificate signed by unknown authority
Redirecting to the above provided url "https://registry-1.docker.io/v2/library/openjdk/manifests/13"
gives the following message:
{"errors":[{"code":"UNAUTHORIZED","message":"authentication required","detail":[{"Type":"repository","Class":"","Name":"library/openjdk","Action":"pull"}]}]}
Note: I’m using work Environment.
Hope you help me to solve the error, thanks in advance.
2
Answers
This is coming months late and I assume that you have figured it out already but for the sake of someone else that has the same issue, I’ll share what worked for me.
First thing I did was to check the name of the container for the
buildkit:build-stable-1
image, as this was automatically generated for me:Next, stop the container:
Finally, remove the container:
Afterwards, I started the build process. I did encounter this issue a few times but stopping and removing the container always worked. I am relatively new to docker so I am not sure why this happens, but I hope this helps someone.
Just adding to the answer provided by thenoobinventor. That answer was a huge help for my issue, but an additional step was needed.
It wasn’t until I finally ran across this question and the referenced answer that I noticed a key part of my build log. The first line included "booting buildkit".
I had forgotten that, in an earlier effort, I had created a new builder instance that used the moby/buildkit for doing ARM builds. Stopping the buildkit container as stated in the referenced answer solved part of the problem, but Docker would spin it back up on the next build because it was set as my default builder.
List your current builders:
If the builder with a driver/endpoint of "docker" is not the current builder (as indicated with an asterisk after the name), you can use the same "builder" command to switch to the desired builder, which in my case was named "default":
Once I did this, Docker would FINALLY build my image.