How to configure proxy setting for docker in Centos 7
HTTP/HTTPS proxy
The Docker daemon uses theHTTP_PROXY, HTTPS_PROXY, and NO_PROXY environmental variables in
its start-up environment to configure HTTP or HTTPS proxy behavior. You cannot configurethese environment variables using the
daemon.json file.This example overrides the default
docker.service file.If you are behind an HTTP or HTTPS proxy server, for example in corporate settings, you will need to add this configuration in the Docker systemd service file.
-
Create a systemd drop-in directory for the docker service:
$ mkdir -p /etc/systemd/system/docker.service.d -
Create a file called
/etc/systemd/system/docker.service.d/http-proxy.confthat adds theHTTP_PROXYenvironment variable:
Or, if you are behind an HTTPS proxy server, create a file called[Service] Environment="HTTP_PROXY=http://proxy.example.com:80/"/etc/systemd/system/docker.service.d/https-proxy.confthat adds theHTTPS_PROXYenvironment variable:
[Service] Environment="HTTPS_PROXY=https://proxy.example.com:443/" -
If you have internal Docker registries that you need to contact without
proxying you can specify them via the
NO_PROXYenvironment variable:
Or, if you are behind an HTTPS proxy server:Environment="HTTP_PROXY=http://proxy.example.com:80/" "NO_PROXY=localhost,127.0.0.1,docker-registry.somecorporation.com"
Environment="HTTPS_PROXY=https://proxy.example.com:443/" "NO_PROXY=localhost,127.0.0.1,docker-registry.somecorporation.com" -
Flush changes:
$ sudo systemctl daemon-reload -
Restart Docker:
$ sudo systemctl restart docker -
Verify that the configuration has been loaded:
Or, if you are behind an HTTPS proxy server:$ systemctl show --property=Environment docker Environment=HTTP_PROXY=http://proxy.example.com:80/
$ systemctl show --property=Environment docker Environment=HTTPS_PROXY=https://proxy.example.com:443/
Comments
Post a Comment