gpt4 book ai didi

docker - Docker构建失败: “unsatisfable contraints”

转载 作者:行者123 更新时间:2023-12-02 21:15:39 26 4
gpt4 key购买 nike

我已经写了这个简单的Dockerfile:

FROM alpine

WORKDIR /usr/src

RUN apk add --no-cache curl jq
RUN mkdir /env

COPY src/* /usr/src/
RUN chmod u+x /usr/src/*.sh

CMD /usr/src/wsec.sh

当我尝试生成图像时,出现以下错误消息:
Sending build context to Docker daemon  43.52kB
Step 1 : FROM alpine
---> 3fd9065eaf02
Step 2 : WORKDIR /usr/src
---> Using cache
---> 4c7b79dc4239
Step 3 : RUN apk add --no-cache curl jq
---> Running in 0cf83217477a
fetch http://dl-cdn.alpinelinux.org/alpine/v3.7/main/x86_64/APKINDEX.tar.gz
WARNING: Ignoring http://dl-cdn.alpinelinux.org/alpine/v3.7/main/x86_64/APKINDEX.tar.gz: temporary error (try again later)
fetch http://dl-cdn.alpinelinux.org/alpine/v3.7/community/x86_64/APKINDEX.tar.gz
WARNING: Ignoring http://dl-cdn.alpinelinux.org/alpine/v3.7/community/x86_64/APKINDEX.tar.gz: temporary error (try again later)
ERROR: unsatisfiable constraints:
curl (missing):
required by: world[curl]
jq (missing):
required by: world[jq]
The command '/bin/sh -c apk add --no-cache curl jq' returned a non-zero code: 2

最佳答案

主 Alpine 存储库http://dl-cdn.alpinelinux.org/alpine可能暂时不可用。就像您的情况一样。为了不受此问题的影响,我们应在我们的 Alpine 图像中添加其他 Alpine 存储库:

http://dl-2.alpinelinux.org
http://dl-3.alpinelinux.org
http://dl-4.alpinelinux.org
http://dl-5.alpinelinux.org

因此,最终的 Dockerfile是:
FROM alpine

WORKDIR /usr/src

RUN echo "http://dl-2.alpinelinux.org/alpine/v3.7/main" >> /etc/apk/repositories && \
echo "http://dl-2.alpinelinux.org/alpine/v3.7/community" >> /etc/apk/repositories && \
echo "http://dl-3.alpinelinux.org/alpine/v3.7/main" >> /etc/apk/repositories && \
echo "http://dl-3.alpinelinux.org/alpine/v3.7/community" >> /etc/apk/repositories && \
echo "http://dl-4.alpinelinux.org/alpine/v3.7/main" >> /etc/apk/repositories && \
echo "http://dl-4.alpinelinux.org/alpine/v3.7/community" >> /etc/apk/repositories && \
echo "http://dl-5.alpinelinux.org/alpine/v3.7/main" >> /etc/apk/repositories && \
echo "http://dl-5.alpinelinux.org/alpine/v3.7/community" >> /etc/apk/repositories

RUN apk add --no-cache curl jq

RUN mkdir /env

COPY src/* /usr/src/
RUN chmod u+x /usr/src/*.sh

CMD /usr/src/wsec.sh

关于docker - Docker构建失败: “unsatisfable contraints”,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51056522/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com