Apple M1 使用 dockerfile-maven-plugin 构建镜像失败

在Mac上解决Dockerfile-maven-plugin构建镜像失败的问题
本文档介绍了一种在macOS环境下解决Dockerfile-maven-plugin构建镜像失败的方法。通过安装socat,将UNIX套接字代理到TCP端口,并设置DOCKER_HOST环境变量,成功绕过了由于库不支持macOS aarch64架构导致的连接错误。最后,展示了镜像构建成功的完整流程。

解决方案

安装 socat

brew install socat

使用 socat 将 unix socket 代理到 tcp 端口

socat TCP-LISTEN:2375,range=127.0.0.1/32,reuseaddr,fork UNIX-CLIENT:/var/run/docker.sock

设置环境变量 DOCKER_HOST

export DOCKER_HOST=tcp://127.0.0.1:2375

镜像构建成功

[INFO] --- dockerfile-maven-plugin:1.4.13:build (shardingsphere-proxy-bin) @ shardingsphere-integration-test-fixture ---
[INFO] dockerfile: null
[INFO] contextDirectory: /Users/wuweijie/IdeaProjects/shardingsphere/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture
[INFO] Building Docker context /Users/wuweijie/IdeaProjects/shardingsphere/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture
[INFO] Path(dockerfile): null
[INFO] Path(contextDirectory): /Users/wuweijie/IdeaProjects/shardingsphere/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture
[INFO] 
[INFO] Image will be built as apache/shardingsphere-proxy-test:latest
[INFO] 
[INFO] Step 1/11 : FROM openjdk:8-jdk-alpine
[INFO] 
[INFO] Pulling from library/openjdk
[INFO] Image 0362ad1dd800: Pulling fs layer
[INFO] Image 571218f61883: Pulling fs layer
[INFO] Image abe576d65b4c: Pulling fs layer
[INFO] Image 571218f61883: Downloading
[INFO] Image 571218f61883: Verifying Checksum
[INFO] Image 571218f61883: Download complete
[INFO] Image 0362ad1dd800: Downloading
[INFO] Image abe576d65b4c: Downloading
[INFO] Image 0362ad1dd800: Verifying Checksum
[INFO] Image 0362ad1dd800: Download complete
[INFO] Image 0362ad1dd800: Extracting
[INFO] Image 0362ad1dd800: Pull complete
[INFO] Image 571218f61883: Extracting
[INFO] Image 571218f61883: Pull complete
[INFO] Image abe576d65b4c: Verifying Checksum
[INFO] Image abe576d65b4c: Download complete
[INFO] Image abe576d65b4c: Extracting
[INFO] Image abe576d65b4c: Pull complete
[INFO] Digest: sha256:94792824df2df33402f201713f932b58cb9de94a0cd524164a0f2283343547b3
[INFO] Status: Downloaded newer image for openjdk:8-jdk-alpine
[INFO]  ---> e4105db9d469
[INFO] Step 2/11 : ARG APP_NAME
[INFO] 
[INFO]  ---> Running in a45c265a7eff
[INFO] Removing intermediate container a45c265a7eff
[INFO]  ---> 46a87b168ea2
[INFO] Step 3/11 : ADD target/${APP_NAME}.tar.gz /opt
[INFO] 
[INFO]  ---> a931814
ERROR] Failed to execute goal org.xolstice.maven.plugins:protobuf-maven-plugin:0.6.1:compile (default) on project access-gateway-broker-grpc-api: Unable to resolve artifact: Could not transfer artifact com.google.protobuf:protoc:exe:linux-x86_64:3.7.1 from/to nexus (https://nexus.crd.tp-link.com/repository/maven-public/): Transfer failed for https://nexus.crd.tp-link.com/repository/maven-public/com/google/protobuf/protoc/3.7.1/protoc-3.7.1-linux-x86_64.exe [ERROR] com.google.protobuf:protoc:exe:3.7.1 [ERROR] [ERROR] from the specified remote repositories: [ERROR] nexus (https://nexus.crd.tp-link.com/repository/maven-public/, releases=true, snapshots=true), [ERROR] smb-nexus (https://nexus.crd.tp-link.com/repository/smb-maven-public/, releases=true, snapshots=true), [ERROR] cdd-nexus (https://nexus.crd.tp-link.com/repository/cdd-maven-public/, releases=true, snapshots=true), [ERROR] tplink-mvn (http://rdsource.tp-link.com/maven-public/, releases=true, snapshots=false) [ERROR] Path to dependency: [ERROR] 1) com.tplink:access-gateway-broker-grpc-api:jar:1.0.0-SNAPSHOT [ERROR] 2) com.google.protobuf:protoc:exe:linux-x86_64:3.7.1 [ERROR] [ERROR] : Unknown host nexus.crd.tp-link.com [ERROR] -> [Help 1] [ERROR] Failed to execute goal org.xolstice.maven.plugins:protobuf-maven-plugin:0.6.1:compile (default) on project access-gateway-security-grpc-api: Unable to resolve artifact: Could not transfer artifact com.google.protobuf:protoc:exe:linux-x86_64:3.7.1 from/to nexus (https://nexus.crd.tp-link.com/repository/maven-public/): Transfer failed for https://nexus.crd.tp-link.com/repository/maven-public/com/google/protobuf/protoc/3.7.1/protoc-3.7.1-linux-x86_64.exe [ERROR] com.google.protobuf:protoc:exe:3.7.1 [ERROR] [ERROR] from the specified remote repositories: [ERROR] nexus (https://nexus.crd.tp-link.com/repository/maven-public/, releases=true, snapshots=true), [ERROR] smb-nexus (https://nexus.crd.tp-link.com/repository/smb-maven-public/, releases=true, snapshots=true), [ERROR] cdd-nexus (https://nexus.crd.tp-link.com/repository/cdd-maven-public/, releases=true, snapshots=true), [ERROR] tplink-mvn (http://rdsource.tp-link.com/maven-public/, releases=true, snapshots=false) [ERROR] Path to dependency: [ERROR] 1) com.tplink:access-gateway-security-grpc-api:jar:1.0.0-SNAPSHOT [ERROR] 2) com.google.protobuf:protoc:exe:linux-x86_64:3.7.1 [ERROR] [ERROR] : Unknown host nexus.crd.tp-link.com: Temporary failure in name resolution [ERROR] -> [Help 1] [ERROR] [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. [ERROR] Re-run Maven using the -X switch to enable full debug logging. [ERROR] [ERROR] For more information about the errors and possible solutions, please read the following articles: [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException [ERROR] [ERROR] After correcting the problems, you can resume the build with the command [ERROR] mvn <args> -rf :access-gateway-broker-grpc-api
最新发布
08-05
评论 14
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

wuweijie@apache.org

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值