linux 错误:无法解决:无法获取oauth令牌:Post“https://auth.docker.io/token“:dial tcp:输入输出超时

wqnecbli  于 2023-06-21  发布在  Linux
关注(0)|答案(1)|浏览(1298)

我试图在我的M1 max MacBook上为我的java文件构建一个docker镜像,我的dockerfile:

FROM openjdk:8-alpine
COPY . /src/java
WORKDIR /src/java
RUN ["javac","greenchallenge.java"]
ENTRYPOINT ["java","greenchallenge"]

构建映像所遵循的步骤:
1.使用以下命令创建了一个新的生成器:docker buildx create --name pibuilder(* 我想使用多架构功能 *)
1.已使用以下命令初始化构建器:docker buildx use pibuilder
1.构建映像并使用以下命令推送:

docker buildx build --platform linux/amd64,linux/arm64,linux/arm/v7 -t my_java:latest -t my_java:1.0.0 --push .

运行step-3后,得到如下日志:

[+] 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

**注意:**我使用的是工作环境,我也绕过了proxy。**注:**如前所述here我设置了"buildkit":false并在终端中使用了docker login

希望你能帮我解决这个错误,先谢谢了。

bis0qfac

bis0qfac1#

buildkit选项设置为false是不够的,如果您在代理后面,您应该设置**HTTP_PROXY和HTTPS_PROXY` env变量才能使其工作。
在Windows上,在CMD中:

set HTTP_PROXY=YourProxyUrl:Port
set HTTPS_PROXY=YourProxyUrl:Port

在GitBash shell中的Windows上,或在MacOs shell上:

export HTTP_PROXY=YourProxyUrl:Port
export HTTPS_PROXY=YourProxyUrl:Port

相关问题