Jenkins构建在除一个节点上的所有节点上均失败
构建Docker镜像时出现错误
Could not build image: The command '/bin/sh -c apk --no-cache update && apk --no-cache add python py-pip py-setuptools ca-certificates groff && pip --no-cache-dir install cfn-lint && pip --no-cache-dir install awscli==${AWS_CLI_VERSION}' returned a non-zero code: 4 -> [Help 1]
我的docker文件是
FROM openjdk:8-jre-alpine
# Versions: https://pypi.python.org/pypi/awscli#downloads
ENV AWS_CLI_VERSION 1.16.100
RUN apk --no-cache update && \
apk --no-cache add python py-pip py-setuptools ca-certificates groff && \
pip --no-cache-dir install cfn-lint && \
pip --no-cache-dir install awscli==${AWS_CLI_VERSION}
我该如何解决这个问题?
最佳答案
刚刚经过测试,它对我有用,因此可能与某些网络问题有关。我的建议是尝试将此RUN
命令分解为多个RUN
(或至少分为两个),以便找出哪个命令正在返回错误代码4
。
FROM openjdk:8-jre-alpine
# Versions: https://pypi.python.org/pypi/awscli#downloads
ENV AWS_CLI_VERSION 1.16.100
RUN apk --no-cache update && \
apk --no-cache add python py-pip py-setuptools ca-certificates groff
RUN pip --no-cache-dir install cfn-lint && \
pip --no-cache-dir install awscli==${AWS_CLI_VERSION}
假设
由于
apk
使用wget
In addition to local repositories, the apk utility uses busybox wget to fetch packages using http:, https: or ftp: protocols. The following is a valid repository file:
错误代码
4
可能来自wget
,如果是这样,则意味着Network failure.
因此,我的猜测是某些代理无法访问软件包下载位置。请检查您是否可以从这些代理访问
http://dl-cdn.alpinelinux.org
。为此,请尝试使用wget
进行的首次获取在Dockerfile
中运行apk
。RUN wget http://dl-cdn.alpinelinux.org/alpine/v3.9/main/x86_64/APKINDEX.tar.gz
关于docker -/bin/sh -c apk --no-cache返回非零代码4,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56855928/