Docker : cannot access internet from container
I've solved the problem, and it wasn't at all related to Docker. It was just a proxy problem.
I was testing by running an ubuntu:14.10 container, and by running apt-get update
, which wasn't working.
The solution was to edit the /etc/apt/apt.conf file in the container to add the proxy information. After that, apt-get update
was working like a charm.
Related videos on Youtube
Elouan Keryell-Even
Updated on September 18, 2022Comments
-
Elouan Keryell-Even over 1 year
I am running CentOS 6.6 behind a corporate proxy. I've installed docker, and I had to make some modifications in order for the daemon to access the Docker Hub through the proxy. This part is working fine.
# /etc/sysconfig/docker HTTP_PROXY='http://domain\username:password@proxy:port' HTTPS_PROXY='https://domain\username:password@proxy:port' export HTTP_PROXY HTTPS_PROXY
My problem is that my containers seems like they can't access the internet (apt-get update times out, can't get the user-guide web app to work, ...).
I have
sysctl -w net.ipv4.ip_forward=1
on both host and containers.I've tried multiple things I've found with a google research, but without success :
- adding option
-p :80
in order to redirect HTTP requests through the host - adding option
--net=host
- adding
--dns 8.8.8.8 --dns 8.8.4.4
(I'm not even able to ping the dns servers when doing this) - setting
http_proxy
andhttps_proxy
variables in the containers
If you need me to post some output I'll be glad to do it.
- adding option
-
jackdh about 8 yearsThank you this saved me a load of trouble. For others: the proxies need to be formatted like in this answer. askubuntu.com/a/342180/313830