proxy dns docker virtualbox apt-get

proxy docker windows



apt-get in docker detrĂ¡s del proxy corporativo (4)

Estoy intentando configurar un entorno de desarrollo detrás de un servidor proxy corporativo con Docker. Por más que lo intente, no puedo hacer que el contenedor del acoplador se comunique con el servidor proxy.

El servidor proxy y apt-get funcionan bien en el host, que es Ubuntu 12.04

Lo primero que se hace en Dockerfile es intentar configurar las variables proxy:

FROM ubuntu RUN echo ''Acquire::http { Proxy "http://my.proxy.net:8000"; };'' >> /etc/apt/apt.conf.d/01proxy ENV HTTP_PROXY http://my.proxy.net:8000 ENV http_proxy http://my.proxy.net:8000 ENV HTTPS_PROXY https://my.proxy.net:8000 ENV https_proxy https://my.proxy.net:8000 RUN apt-get update && apt-get install -y build-essential

Tira bien de la imagen, establece las variables, pero cuando llega a apt-get update, intenta por un momento y luego falla con:

W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/trusty/InRelease W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/trusty-updates/InRelease W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/trusty-security/InRelease W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/trusty/Release.gpg Could not resolve ''my.proxy.net'' W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/trusty-updates/Release.gpg Could not resolve ''my.proxy.net'' W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/trusty-security/Release.gpg Could not resolve ''my.proxy.net'' W: Some index files failed to download. They have been ignored, or old ones used instead.

Estas variables que he configurado son consistentes con la instalación de host Linux (Ubuntu 12.04 en VirtualBox, si eso importa)

También tengo configurado / etc / default / docker con:

export http_proxy="http://my.proxy.net:8000" export http_proxy="https://my.proxy.net:8000"

¿Alguna idea?

ACTUALIZAR:

Parece que esto es un problema con DNS, no necesariamente con el servidor proxy. El host /etc/resolve.conf contiene:

# 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 127.0.0.1 search dhcp.mycompany.com

El host es una virtualbox vm que se ejecuta en un cuadro de Windows 7, y he encontrado varias soluciones a medias que en su mayoría parecen no funcionar. No importa lo que intente, no puedo lograr que resuelva el nombre de host del servidor proxy


El problema terminó siendo con DNS. Docker se ejecuta en Ubuntu, que es, en sí mismo, un sistema operativo invitado en VirtualBox. Debido a su propio juego de palabras virutalizante, asignó un servidor de nombres de 127.0.0.1 en resolv.conf.

Cuando esto sucede, Docker se asignará a sí mismo un servidor de nombres DNS de 8.8.8.8 (servidor de nombres de google) ya que el servidor local se refiere al contenedor acoplable y no al servidor.

Para arreglar esto, fui hasta Windows y corrí

ipconfig /all

Y obtuve la dirección IP de mis servidores DNS portátiles. Los agregué a DOCKER_OPTS en el archivo de configuración con --dns = my.dns.ip.address y reinicié la ventana acoplable, y las otras medidas que tomé para obtener el proxy funcionaron bien.


Añadiendo a la solución anterior, también podemos hacer lo siguiente debajo de un contenedor para instalarlo con apt-get

En la máquina virtual, después de instalar la ventana acoplable al ejecutar las imágenes en el contenedor usando la configuración de proxy

docker run -it ubuntu: 14.04

apt-get install wget

Este comando no podrá extraer paquetes de apt-get, para hacerlo use el siguiente comando

Docker Run -it --net = host ubuntu: 14.04

exportar http_proxy = "proxy: puerto"

apt-get install wget


Si está construyendo detrás del firewall, DEBE usar Docker 1.9.x build-args.

Crear un Dockerfile sin los argumentos de compilación falla y bloquea de la siguiente manera:

3b0d8aa7c417: Pull complete Digest: sha256:dc31e6056d314218689f028b51a58b2ca69b1dfdc5f33ead52b9351e9a19ee85 Status: Downloaded newer image for nodesource/trusty:4.2.3 ---> e17bee681d8f Step 2 : RUN apt-get update ---> Running in bdaf0006ccbd

Apt-get bloquea aquí porque no tiene conectividad con archive.ubuntu.com ... Puede verificarlo ejecutando la imagen ...

# docker run -ti --net=host --rm nodesource/trusty:4.2.3 bash root@pppdc9prd9rj:/usr/src/app# apt-get update 0% [Connecting to archive.ubuntu.com (91.189.92.201)]^C root@pppdc9prd9rj:/usr/src/app# ping archive.ubuntu.com PING archive.ubuntu.com (91.189.91.24) 56(84) bytes of data. ^C --- archive.ubuntu.com ping statistics --- 3 packets transmitted, 0 received, 100% packet loss, time 1999ms

Usar build-arg resuelve el problema ...

# docker build -t migrator --build-arg http_proxy=$HTTP_PROXY . arg http_proxy=$HTTP_PROXY . Sending build context to Docker daemon 3.333 MB Step 1 : FROM nodesource/trusty:4.2.3 ---> e17bee681d8f Step 2 : RUN apt-get update ---> Running in 019b32d09a77 Ign http://archive.ubuntu.com trusty InRelease Get:1 http://archive.ubuntu.com trusty-updates InRelease [65.9 kB] Get:2 http://archive.ubuntu.com trusty-security InRelease [65.9 kB] Get:3 http://archive.ubuntu.com trusty Release.gpg [933 B] Get:4 http://archive.ubuntu.com trusty Release [58.5 kB] Get:5 http://archive.ubuntu.com trusty-updates/main Sources [326 kB] Get:6 http://archive.ubuntu.com trusty-updates/restricted Sources [5217 B] Get:7 http://archive.ubuntu.com trusty-updates/universe Sources [1


Un par de comentarios, después de mi propia experiencia :

  • asegúrese de usar una url http para HTTPS_PROXY.
  • usar variables proxy minúsculas en el propio Dockerfile
  • use ambas variables proxy de casos en el perfil del acoplador (en mi caso, estaba en /var/lib/boot2docker/profile )
  • en todos los casos, establezca una variable no_proxy / NO_PROXY (para .company,.sock,localhost,127.0.0.1,::1 )
  • no olvide incluir las credenciales en la url proxy si su proxy solicita autenticación.