Primero debemos saber si utilizamos systemd o no, lo podemos averiguar con el siguiente comando:
readlink -v
/sbin/init
o con el siguiente:
ps -p1 | grep "init|upstart|systemd"
Configurar proxy para Docker en sistemas sin systemd
Debemos crear un fichero, si no existe ya, en /etc/sysconfig/ , llamado ‘docker’
vi /etc/sysconfig/docker
Con la siguiente información, adaptada a nuestras necesidades:
HTTP_PROXY='http://user:password@proxy-host:proxy-port'
HTTPS_PROXY='http://user:password@proxy-host:proxy-port'
Una vez hecho esto sólo tenemos que reiniciar el servicio:
service docker restart
Configurar proxy para Docker en sistemas con systemd
Create the required Docker folder named docker.service.d.
mkdir -p /etc/systemd/system/docker.service.d
Create the required Docker file named proxy.conf.
touch /etc/systemd/system/docker.service.d/proxy.conf
Edit the Proxy configuration file from the Docker service.
vi /etc/systemd/system/docker.service.d/proxy.conf
If your proxy requires authentication, add the the following configuration to the Proxy file.
Environment="HTTP_PROXY=http://bruno:kamisama123@192.168.0.1:3128"
Environment="HTTPS_PROXY=http://bruno:kamisama123@192.168.0.1:3128"
Environment="NO_PROXY="localhost,127.0.0.1,::1"
In our example, we set the proxy server 192.168.10.1 using the 3128 port.
In our example, we authenticate the Docker proxy access using the username bruno and the password kamisama123.
If your proxy does not require authentication, use the following proxy configuration instead.
Environment="HTTP_PROXY=http://192.168.0.1:3128"
Environment="HTTPS_PROXY=http://192.168.0.1:3128"
Environment="NO_PROXY="localhost,127.0.0.1,::1"
In our example, we set the proxy server 192.168.10.1 using the 3128 port.
Reload systemd manager configuration.
systemctl daemon-reload
Restart the Docker service.
systemctl restart docker.service
Congratulations! You have finished the Docker proxy configuration.
Fuente: https://techexpert.tips/es/docker-es/docker-configuracion-de-proxy-en-ubuntu-linux/