'error: failed to solve: failed to fetch oauth token: Post "https://auth.docker.io/token": dial tcp: i/o timeout

I'm trying to build a docker image for my java file on my M1 max MacBook, my dockerfile:

FROM openjdk:8-alpine
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 47.2s (7/7) FINISHED                                               
 => [internal] booting buildkit                                           15.8s
 => => pulling image moby/buildkit:buildx-stable-1                        15.2s
 => => creating container buildx_buildkit_javabuildernew40                 0.6s
 => [internal] load build definition from dockerfile                       0.0s
 => => transferring dockerfile: 351B                                       0.0s
 => [internal] load .dockerignore                                          0.0s
 => => transferring context: 2B                                            0.0s
 => ERROR [linux/arm/v7 internal] load metadata for docker.io/library/op  31.3s
 => CANCELED [linux/amd64 internal] load metadata for docker.io/library/  31.3s
 => CANCELED [linux/arm64 internal] load metadata for docker.io/library/  31.3s
 => [auth] library/openjdk:pull token for registry-1.docker.io             0.0s
------
 > [linux/arm/v7 internal] load metadata for docker.io/library/openjdk:8-alpine:
------
dockerfile:1
--------------------
   1 | >>> FROM openjdk:8-alpine
   2 |     COPY . /src/java
   3 |     WORKDIR /src/java
--------------------
error: failed to solve: failed to fetch oauth token: Post "https://auth.docker.io/token": dial tcp: i/o timeout

Note: I'm using work Environment, I bypassed proxy as well. Note: As mentioned here I set "buildkit":false and used docker login in terminal.

Hope you help me to solve the error, thanks in advance.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source