skip to Main Content

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:

  1. Created a new builder using: docker buildx create --name pibuilder
    (I wanted to use the multi architecture feature)
  2. Initialed the builder using: docker buildx use pibuilder .
  3. 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


  1. 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:

    docker ps
    

    Next, stop the container:

    docker stop buildx_buildkit_trusting_moore0
    

    Finally, remove the container:

    docker rm buildx_buildkit_trusting_moore0
    

    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.

    Login or Signup to reply.
  2. 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:

    docker builder ls
    

    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":

    docker builder use default
    

    Once I did this, Docker would FINALLY build my image.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search