Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Docker on a linux VMware machine: error with apt-get and proxy

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

like image 234
Nicolas Rosewick Avatar asked Feb 15 '18 14:02

Nicolas Rosewick


1 Answers

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

like image 147
Tarun Lalwani Avatar answered Sep 20 '22 23:09

Tarun Lalwani