docker-compose 构建 nginx : network error (check Internet connection and firewall)

标签 docker nginx docker-compose docker-build

您好,我正在尝试使用 nginx 构建容器,但是,在执行这些步骤后我无法继续前进:

Building nginx
Step 1/17 : FROM nginx:alpine
---> 377c0837328f
Step 2/17 : LABEL maintainer="Mahmoud Zalt <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="caa7aba2a7a5bfae8ab0aba6bee4a7af" rel="noreferrer noopener nofollow">[email protected]</a>"
---> Running in 8d53a074e85a
Removing intermediate container 8d53a074e85a
---> 6053f271c802
Step 3/17 : COPY nginx.conf /etc/nginx/
---> ba65da2b9c43
Step 4/17 : ARG CHANGE_SOURCE=false
---> Running in 1d31fc76ab76
Removing intermediate container 1d31fc76ab76
---> 8864e5fb904e
Step 5/17 : RUN if [ ${CHANGE_SOURCE} = true ]; then sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/' /etc/apk/repositories ;fi
---> Running in d0f8c3bd67dd
Removing intermediate container d0f8c3bd67dd
---> c6e0c7aaf66f
Step 6/17 : RUN apk update && apk upgrade && apk --update add logrotate && apk add --no-cache openssl && apk add --no-cache bash
---> Running in 37305c5f0e55
fetch http://dl-cdn.alpinelinux.org/alpine/v3.10/main/x86_64/APKINDEX.tar.gz
ERROR: http://dl-cdn.alpinelinux.org/alpine/v3.10/main: network error (check Internet connection and firewall)
WARNING: Ignoring APKINDEX.00740ba1.tar.gz: No such file or directory
fetch http://dl-cdn.alpinelinux.org/alpine/v3.10/community/x86_64/APKINDEX.tar.gz
ERROR: http://dl-cdn.alpinelinux.org/alpine/v3.10/community: network error (check Internet connection and firewall)
WARNING: Ignoring APKINDEX.d8b2a6f4.tar.gz: No such file or directory
2 errors; 36 distinct packages available
ERROR: Service 'nginx' failed to build: The command '/bin/sh -c apk update && apk upgrade && apk --update add logrotate && apk add --no-cache openssl && apk add --no-cache bash' returned a non-zero code: 2

我使用的是 ubuntu 18.04 你能告诉我如何修复它吗?

最佳答案

从提供的日志来看,问题似乎是网络问题:

 network error (check Internet connection and firewall)

可能的根本原因:

  • 您的机器无法访问互联网
  • 您正在使用代理访问互联网
  • 您的防火墙不允许访问

关于docker-compose 构建 nginx : network error (check Internet connection and firewall),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61128896/

相关文章:

docker - 有没有办法从标准输入提供 docker-compose 环境文件?

docker - 如何在 Docker-Compose 中一起使用主机网络和任何其他用户定义的网络?

node.js - 作为守护进程运行的带有 redis 的 Docker 容器不运行

php - Docker 在具有 curl 支持的 alpine 图像上构建 php 失败。我该如何解决?

windows - NGINX cmd 命令不起作用

nginx www 重定向(除其他子域外)

linux - Nginx 错误 : unknown directive rewrite

java - Docker 和 Java - 字体配置问题

python - Jupyterhub/单用户共享卷

selenium-webdriver - 加载共享库时出错 : libnss3. 所以:无法打开共享对象文件:使用 Selenium Gitlab 管道和 docker 没有这样的文件或目录