我试图在我的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
。
希望你能帮我解决这个错误,先谢谢了。
1条答案
按热度按时间bis0qfac1#
将
buildkit
选项设置为false
是不够的,如果您在代理后面,您应该设置**HTTP_PROXY
和HTTPS_PROXY` env变量才能使其工作。在Windows上,在CMD中:
在GitBash shell中的Windows上,或在MacOs shell上: