码头工人由于高山错误而无法建造

Bha*_*ran 0 docker alpine-linux

嗨,我正在尝试构建一个docker,Docker文件看起来像这样。

FROM alpine

LABEL description "Nginx + uWSGI + Flask based on Alpine Linux and managed by Supervisord"

# Copy python requirements file
COPY requirements.txt /tmp/requirements.txt

RUN apk add --no-cache \
    python3 \
    bash \
    nginx \
    uwsgi \
    uwsgi-python3 \
    supervisor && \
    python3 -m ensurepip && \
    rm -r /usr/lib/python*/ensurepip && \
    pip3 install --upgrade pip setuptools && \
    pip3 install -r /tmp/requirements.txt && \
    rm /etc/nginx/conf.d/default.conf && \
    rm -r /root/.cache

# Copy the Nginx global conf
COPY nginx.conf /etc/nginx/
# Copy the Flask Nginx site conf
COPY flask-site-nginx.conf /etc/nginx/conf.d/
# Copy the base uWSGI ini file to enable default dynamic uwsgi process number
COPY uwsgi.ini /etc/uwsgi/
# Custom Supervisord config
COPY supervisord.conf /etc/supervisord.conf

# Add demo app
COPY ./app /app
WORKDIR /app

CMD ["/usr/bin/supervisord"]
Run Code Online (Sandbox Code Playgroud)

错误看起来像

Sending build context to Docker daemon  250.9kB
Step 1/11 : FROM alpine
 ---> 196d12cf6ab1
Step 2/11 : LABEL description "Nginx + uWSGI + Flask based on Alpine Linux and managed by Supervisord"
 ---> Using cache
 ---> d8d38c761b8d
Step 3/11 : COPY requirements.txt /tmp/requirements.txt
 ---> Using cache
 ---> cb29eb34ca46
Step 4/11 : RUN apk add --no-cache     python3     bash     nginx     uwsgi     uwsgi-python3     supervisor &&     python3 -m ensurepip &&     rm -r /usr/lib/python*/ensurepip &&     pip3 install --upgrade pip setuptools &&     pip3 install -r /tmp/requirements.txt &&     rm /etc/nginx/conf.d/default.conf &&     rm -r /root/.cache
 ---> Running in 3d568d2620dd
fetch http://dl-cdn.alpinelinux.org/alpine/v3.8/main/x86_64/APKINDEX.tar.gz
WARNING: Ignoring http://dl-cdn.alpinelinux.org/alpine/v3.8/main/x86_64/APKINDEX.tar.gz: could not connect to server (check repositories file)
fetch http://dl-cdn.alpinelinux.org/alpine/v3.8/community/x86_64/APKINDEX.tar.gz
WARNING: Ignoring http://dl-cdn.alpinelinux.org/alpine/v3.8/community/x86_64/APKINDEX.tar.gz: could not connect to server (check repositories file)
ERROR: unsatisfiable constraints:
  bash (missing):
    required by: world[bash]
  nginx (missing):
    required by: world[nginx]
  python3 (missing):
    required by: world[python3]
  supervisor (missing):
    required by: world[supervisor]
  uwsgi (missing):
    required by: world[uwsgi]
  uwsgi-python3 (missing):
    required by: world[uwsgi-python3]
The command '/bin/sh -c apk add --no-cache     python3     bash     nginx     uwsgi     uwsgi-python3     supervisor &&     python3 -m ensurepip &&     rm -r /usr/lib/python*/ensurepip &&     pip3 install --upgrade pip setuptools &&     pip3 install -r /tmp/requirements.txt &&     rm /etc/nginx/conf.d/default.conf &&     rm -r /root/.cache' returned a non-zero code: 6
Run Code Online (Sandbox Code Playgroud)

一个月前,它的建筑还不错。由于对Docker的了解有限,所以我无法弄清楚是什么导致了错误。谷歌的快速搜索导致了这两个链接:link1 link2但是它们都不起作用。

lov*_*ing 32

-在Ubuntu中

对我来说这是一个 DNS 错误。通过设置 /etc/docker/daemon.json,

{
  "dns": ["8.8.8.8"]
}
Run Code Online (Sandbox Code Playgroud)

然后重新启动 docker,

sudo service docker restart
Run Code Online (Sandbox Code Playgroud)

我能够再次构建图像​​。

https://github.com/gliderlabs/docker-alpine/issues/334#issuecomment-450598069

- 在Windows中

C:/Users/Administrator(or any other Username)/.docker/daemon.json
Run Code Online (Sandbox Code Playgroud)

并添加

{
  ...,
  "dns": ["8.8.8.8"]
}
Run Code Online (Sandbox Code Playgroud)

  • 是的,这就是窍门。 (2认同)

Ami*_*aei 13

尝试重新启动 docker 服务,它对我和其他人有用:

sudo systemctl restart docker docker.service
Run Code Online (Sandbox Code Playgroud)

感谢: https: //github.com/gliderlabs/docker-alpine/issues/334#issuecomment-408826204


mic*_*sna 12

该行:

WARNING: Ignoring http://dl-cdn.alpinelinux.org/alpine/v3.8/main/x86_64/APKINDEX.tar.gz: could not connect to server (check repositories file)
Run Code Online (Sandbox Code Playgroud)

基本上说你要么离线,要么 alpinelinux 存储库已关闭。我在互联网上找不到任何相关信息,但过去发生过几次。或者可能是您和 CDN 之间的网络问题。

您始终可以从http://dl-cdn.alpinelinux.org/alpine/MIRRORS.txt自行选择镜像并像这样设置它:

RUN echo http://repository.fit.cvut.cz/mirrors/alpine/v3.8/main > /etc/apk/repositories; \
    echo http://repository.fit.cvut.cz/mirrors/alpine/v3.8/community >> /etc/apk/repositories
Run Code Online (Sandbox Code Playgroud)

v3.8(根据您的版本更改)


另外,正如 @emix 指出的那样,您永远不应该:latest在基本图像中使用标签。例如3.8,使用 或包含您需要的软件包版本的版本。


小智 7

此类错误通常是由于某些网络问题而发生的。

尝试使用 https 镜像而不是 http。

RUN sed -i -e 's/http:/https:/' /etc/apk/repositories
Run Code Online (Sandbox Code Playgroud)

  • 唯一有效的解决方案。如果您的防火墙阻止 http 站点,则此方法有效。 (2认同)

Bha*_*ran 6

使用标志“ --network host”构建docker解决了该问题。这是链接


归档时间:

查看次数:

2444 次

最近记录:

7 年,4 月 前