【问题标题】:docker-compose build nginx : network error (check Internet connection and firewall)docker-compose build nginx:网络错误(检查互联网连接和防火墙)
【发布时间】:2020-07-22 12:42:57
【问题描述】:

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

Building nginx
Step 1/17 : FROM nginx:alpine
---> 377c0837328f
Step 2/17 : LABEL maintainer="Mahmoud Zalt mahmoud@zalt.me"
---> 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,你能告诉我如何修复它吗?

【问题讨论】:

  • 能否分享您Dockerfile中的代码?
  • 我使用 laradock (laradock.io)
  • 即便如此,laradock 似乎只是为您抽象了Dockerfile 的构建和维护,它应该仍然存在于某个地方。但是,无论如何,正如@Al-waleed Shihadeh 指出的那样,您实际上实际上似乎有一个连接错误。

标签: docker nginx docker-compose docker-build


【解决方案1】:

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

 network error (check Internet connection and firewall)

可能的根本原因:

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

【讨论】:

  • 在我的机器上(ubuntu 18.04 VPS Hosting Goddady)我可以访问互联网。但在码头没有。 docker run busybox ping -c 1 8.8.8.8 PING 8.8.8.8 (8.8.8.8): 56 个数据字节 --- 8.8.8.8 ping 统计 --- 1 个数据包传输,0 个数据包接收,100% 数据包丢失
  • cat /proc/sys/net/ipv4/ip_forward 1
【解决方案2】:

无法从 docker 容器访问外部网络。 除了我自己的域和一些 GoDaddy 特定的域之外,我无法从我的 docker 容器访问任何外部 IP 地址。

如果我尝试 ping 谷歌 dns,它必须是可以 ping 的,我会得到以下响应:

PING 8.8.8.8 (8.8.8.8): 56 data bytes

--- 8.8.8.8 ping statistics ---
1 packets transmitted, 0 packets received, 100% packet loss```


【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-11-08
    • 2019-02-03
    • 1970-01-01
    • 1970-01-01
    • 2017-05-23
    相关资源
    最近更新 更多