7

I've a VMware machine with linux mint 18.3 on it (the host machine is a windows 10). The host machine is behind a proxy. The guest machine (linux mint) network is configured as "Bridged"?

I try to write a simple Dockerfile on the guest OS and build it but have issues with apt-get command:

FROM ubuntu:xenial 

RUN apt-get update && apt-get install -y \
  bzip2 \
  g++ \
  make \
  ncurses-dev \
  wget \
  zlib1g-dev

It gives me:

Err:1 http://security.ubuntu.com/ubuntu xenial-security InRelease Temporary failure resolving 'security.ubuntu.com'

I tried adding in the Dockerfile:

ENV http_proxy 'http://proxy_adress:3128'
ENV https_proxy 'http://proxy_adress:3128'

and got this error:

Err:1 http://security.ubuntu.com/ubuntu xenial-security InRelease Temporary failure resolving 'proxy_adress'

Do I have to change something in the VMware configuration? or in the Dockerfile?

Thanks

Nicolas Rosewick
  • 1,938
  • 4
  • 24
  • 42
  • Is the package link working? May be try after some time as the error says `Temporary failure`. – Rao Feb 19 '18 at 11:27
  • I tried at different days since last week and have always the same error. – Nicolas Rosewick Feb 19 '18 at 11:33
  • I think I have a start solution : I tried the docker run command by adding the `--net=host` option and it worked ! Now I want to build my docker but docker build do not have a --net parameter ... any idea to circumvent this ? – Nicolas Rosewick Feb 19 '18 at 12:24
  • Do you also have Docker installed on the Windows 10 machine? – sxm1972 Feb 19 '18 at 13:33
  • @sxm1972 I tried the same command (`docker run ubuntu:xenial apt-get update`) and it works. So in the end I could use the windows 10 docker machine to build my docker but it's not very handy to switch between host and guest os ... – Nicolas Rosewick Feb 19 '18 at 13:54
  • @NicolasRosewick, i think this is a possible duplicate of https://stackoverflow.com/questions/46036152/lookup-registry-1-docker-io-no-such-host/46037636#46037636 – Tarun Lalwani Feb 19 '18 at 14:35

4 Answers4

2

You may be in a corporate network I assume and you need to make two changes.

$ cat /etc/resolv.conf

# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
#     DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
nameserver 10.X.Y.Z
search myorg.org

You need to setup these in your docker daemon config. You can do this by creating a file /etc/docker/daemon.json with below content

{
  "dns": ["10.X.Y.Z"],
  "dns-search": ["myorg.org"]
}

The actual values will depend on the output you got.

You also need to change the proxy settings and apply them in your docker service drop-in file. This can be done as listed in below thread

lookup registry-1.docker.io: no such host (Same as what VonC already pointed out)

Nodemailer with Docker

Tarun Lalwani
  • 142,312
  • 9
  • 204
  • 265
  • Thank you the modification of daemon.json + http-proxy.conf made the job ! – Nicolas Rosewick Feb 26 '18 at 12:31
  • However now I've issues to pull new dockers. Example : `docker pull alpine` gives me : `Error response from daemon: Get https://registry-1.docker.io/v2/: Proxy Authentication Required` . Removing informaion from the /etc/systemd/system/docker.service.d/http-proxy.conf file solve the error but will reintroduce the proxy issues from the main question. Should I open a new question ? – Nicolas Rosewick Feb 27 '18 at 14:15
  • Can you try using the proxy like `http://user:password@proxy:port` ? if that doesn't work you should open a new question as it would be different from the original problem – Tarun Lalwani Feb 27 '18 at 14:18
0

Adding ENV to your Dockerfile is not needed at build time: during a docker build, the only one needing a proxy is the docker daemon.

See "Control Docker with systemd", especially the section "HTTP/HTTPS proxy"

/etc/systemd/system/docker.service.d/http-proxy.conf

Environment="HTTP_PROXY=http://proxy.example.com:80/" "NO_PROXY=localhost,127.0.0.1,docker-registry.somecorporatio

Followed by:

$ sudo systemctl daemon-reload
$ sudo systemctl restart docker

Verify that the configuration has been loaded:

$ systemctl show --property=Environment docker
Environment=HTTP_PROXY=http://proxy.example.com:80/
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Thank you for the answer. I tried but nothing changed :( Using `docker run --net=host` it works.. ) – Nicolas Rosewick Feb 20 '18 at 09:12
  • @NicolasRosewick does it work with or without the http-proxy.conf when you are using --net=host? – VonC Feb 20 '18 at 09:13
  • @NicolasRosewick I am not surprised it is working with --net=host. But with bridge, try and add a NO_PROXY=proxy_adress to be sure it does not try to use proxy to resolve the proxy! – VonC Feb 20 '18 at 09:27
  • Ok I tried with : `[Service] Environment="HTTP_PROXY=http://proxy_adress:3128/" "NO_PROXY=http://proxy_adress:3128"` and it didn't work .. Sorry if I miss something from you answer. – Nicolas Rosewick Feb 20 '18 at 09:30
  • @NicolasRosewick NO_PROXY=proxy_adress (no https, or port) – VonC Feb 20 '18 at 09:31
  • I tried with that `[Service] Environment="HTTP_PROXY=http://proxy_adress:3128/" "NO_PROXY=proxy_adress"` and it didn't work also.. FYI here the resolv.conf inside the docker : `search localdomain nameserver 8.8.8.8 nameserver 8.8.4.4` – Nicolas Rosewick Feb 20 '18 at 09:41
0

This will be related to the dns server.

Try to sed the default dns server to another one, 114.114.114.114 for example:

sed -i 's/\(nameserver\) .*/\1 114.114.114.114/' /etc/resolv.conf
Asier Gomez
  • 6,034
  • 18
  • 52
  • 105
Jemy Zhang
  • 1
  • 1
  • 3
0

It looks like your container is unable to resolve the hostname of your proxy. So when you build your container, pass the following additional parameter:

--dns=IP_ADDRESS...

This will do this:

Sets the IP addresses added as nameserver lines to the container's /etc/resolv.conf file. Processes in the container, when confronted with a hostname not in /etc/hosts, will connect to these IP addresses on port 53 looking for name resolution services.

Source: https://docs.docker.com/v17.09/engine/userguide/networking/default_network/configure-dns/

rollstuhlfahrer
  • 3,988
  • 9
  • 25
  • 38