My docker container has no internet

2019-01-04 19:10发布

I had it working allright but now it stopped. I tried the following commands with no avail:

docker run -dns 8.8.8.8 base ping google.com

docker run base ping google.com

sysctl -w net.ipv4.ip_forward=1 - both on the host and on the container

All I get is unknown host google.com. Docker version 0.7.0

Any ideas?

P.S. ufw disabled as well

标签: docker
14条回答
Melony?
2楼-- · 2019-01-04 20:12

The intended way to restart docker is not to do it manually but use the service or init command:

service docker restart
查看更多
来,给爷笑一个
3楼-- · 2019-01-04 20:12

I had the problem on Ubuntu 18.04. However the problem was with the DNS. I was in a corporate network that has its own DNS server and block other DNS servers. This is to block some websites (porn, torrents, ... so on )

To resolve your problem

  1. find your DNS on host machine
  2. use --dns your_dns as suggested by @jobin

    docker run --dns your_dns -it --name cowsay --hostname cowsay debian bash

查看更多
登录 后发表回答