Podman构建Open Liberty容器时featureUtility访问Maven仓库失败
问题
按照Open Liberty容器化指南步骤使用Podman构建容器时,执行RUN features.sh步骤失败,报错CWWKF1390E:无法连接配置的Maven仓库。奇怪的是,容器内执行yum install nano和curl http://www.google.com都能正常联网,工作环境存在透明代理。同时有两个疑问:
- 为什么
features.sh无法访问网络? - 错误信息为何提及Maven而非Open Liberty?
构建日志及错误信息
C:\dev\rn-container\guide-containerize-podman>podman build -t system:1.0-SNAPSHOT finish/system/. STEP 1/8: FROM icr.io/appcafe/open-liberty:kernel-slim-java11-openj9-ubi Trying to pull icr.io/appcafe/open-liberty:kernel-slim-java11-openj9-ubi... Getting image source signatures Checking if image destination supports signatures Copying blob sha256:9d876d7610f48b3b4c1fc2a7b9583ad2ec74b526b5a44beff535c389f61c5ee9 Copying blob sha256:930296e19327c9007bd33f3219bb4338cf8a3b20d3fc43c30f6b942cbdce6c51 Copying blob sha256:6d6997a1fd99ba362048be5d498f205f8961a46f7b22cccd6972848997207eff Copying blob sha256:3df7dc3f800e252b9da6f53995188b66dedc36281d6bc79dfcd5c3b4259d80fc Copying blob sha256:013e303ca13cc91712c179536acbef2617daafff1af96037ba3f76d363460cee Copying blob sha256:0ed61360824d890ae6f7caa74dc073f686216d42734f5de00745b68163d12100 Copying blob sha256:8a9b1619fca84c174ec7fb46203df1149e93147e3a41d7ebcd2ead8fa4278a41 Copying blob sha256:c4f8bfb1b69f860bd698322a38d752d10d7d2ecb0334fcb343935919cda94264 Copying blob sha256:03a33c0a3305670f5f0538f25570d7f6a253b327a9594a1147aec3bdf718ab1a Copying blob sha256:66e113d9641154158289e09d043c283cd915d1ac07d53b3c76defa208364bb4c Copying blob sha256:46d83397f193bdbd259c17e6bf7724ce292ce19a7210f570b46ef8a7e3ddc308 Copying blob sha256:6018ccce72d419e19a2568fa66249d97a2d6be5fa3d212f9c997486f1088168c Copying blob sha256:d3f6e09f7ceee9385c62fdbcbdfe5039b38e44814dd96eee4bb890ed59effa79 Copying blob sha256:27ba61511e7524f5bf78dc7747f3061b4271622b6be12bd0f352100ff76b637d Copying blob sha256:0f79f8ed1c29c05a15adefcdf4b8747fa99fb615dc07b0e2689e872ec96a1a40 Copying blob sha256:46d0b4827a40eff712cab075bc04755781e783c322e6314d07c17600ce3c2cd8 Copying blob sha256:3777e08b6ba97f913814cd7528ae11e7f12e97dcc143d47c2c53f733f1a085f5 Copying config sha256:7f71d47dd47ee9a219206aa774a4398180139b2ebce10658e310bacbb42df06b Writing manifest to image destination Storing signatures STEP 2/8: ARG VERSION=1.0 --> a6f2921a0454 STEP 3/8: ARG REVISION=SNAPSHOT --> 59a154f1ae5f STEP 4/8: LABEL org.opencontainers.image.authors="Your Name" org.opencontainers.image.vendor="Open Liberty" org.opencontainers.image.url="local" org.opencontainers.image.source="https://github.com/OpenLiberty/guide-containerize-podman" org.opencontainers.image.version="$VERSION" org.opencontainers.image.revision="$REVISION" vendor="Open Liberty" name="system" version="$VERSION-$REVISION" summary="The system microservice from the Containerizing microservices with Podman guide" description="This image contains the system microservice running with the Open Liberty runtime." --> 6d5a73d3d417 STEP 5/8: COPY --chown=1001:0 src/main/liberty/config /config/ --> 1caaf3f0abeb STEP 6/8: RUN features.sh + SNIPPETS_SOURCE=/opt/ol/helpers/build/configuration_snippets + SNIPPETS_TARGET=/config/configDropins/overrides + SNIPPETS_TARGET_DEFAULTS=/config/configDropins/defaults + mkdir -p /config/configDropins/overrides + mkdir -p /config/configDropins/defaults + '[' -n '' ']' + '[' '' == client ']' + '[' '' == embedded ']' + [[ -n '' ]] + '[' '' == true ']' + '[' '' == true ']' + featureUtility installServerFeatures --acceptLicense defaultServer --noCache CWWKF1390E: The configured Maven Repository cannot be reached. Verify that your computer has network access and firewalls are configured correctly, then try the action again. If the connection still fails, the repository server might be temporarily unavailable.
解答
为什么错误信息提及Maven?
Open Liberty的featureUtility工具(features.sh脚本内部会调用它)默认从Maven中央仓库拉取所需的功能扩展包,这些Open Liberty的功能依赖是托管在Maven仓库中的,所以当网络连接失败时,错误会直接指向Maven仓库,本质是拉取Open Liberty功能组件失败,只是存储位置是Maven仓库而已。
为什么features.sh无法访问网络?
容器内的系统命令(如yum、curl)能正常联网,但featureUtility是Java程序,它不会自动继承系统的代理环境变量:
- 工作环境的透明代理对系统级命令生效,但Java进程需要单独配置代理参数才能识别
- Podman构建过程中,默认不会把宿主的代理环境变量传递到容器的build阶段,导致Java程序无法获取代理配置
解决办法
在Dockerfile中添加代理环境变量
在RUN features.sh步骤前添加代理配置,替换为你的实际代理地址:ENV HTTP_PROXY=http://your-proxy-address:port ENV HTTPS_PROXY=http://your-proxy-address:port ENV NO_PROXY=localhost,127.0.0.1给featureUtility添加JVM代理参数
修改features.sh脚本中调用featureUtility的行,添加JVM代理参数:featureUtility installServerFeatures --acceptLicense defaultServer --noCache \ -Dhttp.proxyHost=your-proxy-address \ -Dhttp.proxyPort=port \ -Dhttps.proxyHost=your-proxy-address \ -Dhttps.proxyPort=portPodman构建时传递代理参数
构建时用--build-arg传递代理参数,同时在Dockerfile开头声明对应的ARG:- Dockerfile开头添加:
ARG HTTP_PROXY ARG HTTPS_PROXY ENV HTTP_PROXY=$HTTP_PROXY ENV HTTPS_PROXY=$HTTPS_PROXY - 构建命令:
podman build \ --build-arg HTTP_PROXY=http://your-proxy-address:port \ --build-arg HTTPS_PROXY=http://your-proxy-address:port \ -t system:1.0-SNAPSHOT finish/system/.
- Dockerfile开头添加:
内容的提问来源于stack exchange,提问作者Mr Smith
相关产品推荐
相关产品推荐

