我让它工作正常,但现在停止了.我尝试了以下命令但无济于事:
docker run -dns 8.8.8.8 base ping google.com
docker run base ping google.com
sysctl -w net.ipv4.ip_forward=1 - 在主机和容器上
我得到的只是unknown host google.com.Docker版本0.7.0
有任何想法吗?
PS也被ufw禁用了
我在公司网络上构建Docker映像时遇到问题.我刚刚开始使用Docker,所以我有一个hello-world类型应用程序的以下Dockerfile:
# DOCKER-VERSION 0.3.4
FROM centos:6.4
# Enable EPEL for Node.js
RUN rpm -Uvh http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm
# Install Node.js and npm
RUN yum install -y npm
# Bundle app source
ADD . /src
# Install app dependencies
RUN cd /src; npm install
EXPOSE 8080
CMD ["node", "/src/index.js"]
Run Code Online (Sandbox Code Playgroud)
当我在家里的笔记本电脑上,在我自己的无线网络上构建它时,这很好用.它可以下拉必需的依赖项并正确构建映像.
但是,当我在公司网络上工作时,尝试从download.fedoraproject.org下载RPM时,同样的docker构建失败,并显示以下错误消息:
第2步:运行rpm -Uvh http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm --->在e0c26afe9ed5卷曲中运行:(5)无法'解析代理'some.proxy.address'错误:跳过http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm - 转移失败
在我的公司网络上,我可以通过笔记本电脑轻松访问该URL.但是一旦Docker尝试构建容器,突然间它根本无法解决.对于各种外部资源(apt-get等),这种行为是相同的:它们都可以在公司网络上的笔记本电脑上解决得很好,但Docker无法解决它们.
我没有网络专业知识来弄清楚这里发生了什么.有谁知道为什么在构建Docker容器时会发生这种奇怪的行为?
我无法通过docker-compose容器访问外部网络.
考虑以下docker-compose文件:
version: '2'
services:
nginx:
image: nginx
Run Code Online (Sandbox Code Playgroud)
使用简单的docker run -it nginx bash我设法到达外部IP或Internet IP(ping www.google.com).
另一方面,如果我使用docker-compose并附加到容器,我无法访问外部IP地址/ DNS.
码头信息:
Containers: 0
Running: 0
Paused: 0
Stopped: 0
Images: 1
Server Version: 1.12.1
Storage Driver: aufs
Root Dir: /var/lib/docker/aufs
Backing Filesystem: extfs
Dirs: 7
Dirperm1 Supported: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
Volume: local
Network: bridge null host overlay
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Security Options: apparmor seccomp
Kernel Version: 4.4.0-38-generic
Operating System: Ubuntu …Run Code Online (Sandbox Code Playgroud) 我的智慧结束了这一点,我已经梳理了每一个谷歌的结果,没有任何帮助.
我完全无法让docker容器访问互联网.IP转发已启用(net.ipv4.ip_forward = 1),ufw已关闭,我已尝试添加-dns 8.8.8.8 -dns 8.8.4.4标志.我在谷歌上找到的每一种可能的解决方案都失败了.
任何人都知道如何提供帮助?
尝试重置所有东西,正如这里所推荐的那样,通过告诉我docker -d即使它没有运行也会导致整个事情中断.
当我连接到公司的 VPN 时,我无法通过 Docker 容器访问互联网。例如,运行docker run -it ubuntu apt update将失败,并显示消息“Err:1 http://archive.ubuntu.com/ubuntu focus InRelease
解决‘archive.ubuntu.com’临时失败”
断开 VPN 连接并不能解决问题。(参见解决方法#2)
我有两个解决方法:
docker run -it --net=host ubuntu apt update可以正常工作,但是,这对于我公司的脚本和构建系统来说不是合适的解决方法。它适用于临时工作。# /bin/bash
docker system prune -a
systemctl stop docker
iptables -F
ip link set docker0 down
brctl delbr docker0
systemctl start docker
Run Code Online (Sandbox Code Playgroud)
将允许它再次工作 - 但随后我无法访问公司的内部服务器,而这也是构建我们的软件所需要的。
我已经尝试过这些事情:
我正在解决这个问题的第二周,互联网上没有任何帮助解决我的问题。
问题是,如果不指定 --net=host,我就无法从我的 docker 容器访问互联网。
/home/dnadave> docker run -it --net=host --rm debian:jessie ping 8.8.8.8
PING 8.8.8.8 (8.8.8.8): 56 data bytes
64 bytes from 8.8.8.8: icmp_seq=0 ttl=54 time=12.059 ms
64 bytes from 8.8.8.8: icmp_seq=1 ttl=54 time=11.120 ms
^C--- 8.8.8.8 ping statistics ---
2 packets transmitted, 2 packets received, 0% packet loss
round-trip min/avg/max/stddev = 11.120/11.589/12.059/0.470 ms
/home/dnadave> docker run -it --rm debian:jessie ping 8.8.8.8
PING 8.8.8.8 (8.8.8.8): 56 data bytes
^C--- 8.8.8.8 ping statistics ---
4 packets transmitted, 0 packets received, …Run Code Online (Sandbox Code Playgroud)