Prerequisites
Ensure the following prerequisites have been met before configuring Docker:
-
The http_proxy environment variable has been exported and sourced.
-
The https_proxy environment variable has been exported and sourced.
Configure Proxy for GitHub Access
Create an environment proxy configuration by doing the following:
-
Run the following command to open the /etc/environment file:
vi /etc/environment
-
Add the following to the environment file:
http_proxy=http://proxy_info:proxyPort
https_proxy=http://proxy_info:proxyPort
no_proxy="localhost,127.0.0.1"
-
Log off and then log back in.
You can now hit GitHub with "wget" commands.
Configure Docker
After you have run ./lrctl init to install Docker, complete the following steps to configure Docker to use the proxy:
-
Run the following command to create a systemd drop-in directory for the Docker service:
$ sudo mkdir -p /etc/systemd/system/docker.service.d
-
Do one of the following:Create a file called /etc/systemd/system/docker.service.d/http-proxy.conf that adds the HTTP_PROXY environment variable:[Service] Environment="HTTP_PROXY=http://proxy.example.com:PORT"If you are behind an HTTPS proxy server, create a file called /etc/systemd/system/docker.service.d/https-proxy.conf that adds the HTTPS_PROXY environment variable:[Service] Environment="HTTPS_PROXY=https://proxy.example.com:PORT"
-
Run the following command to flush the changes:
$ sudo systemctl daemon-reload
-
Run the following command to restart Docker:
$ sudo systemctl restart docker
-
Verify that Docker is able to pull images from a repository by running the following command:
$ docker run hello-world
-
Update the ~/.docker/config.json file by adding the following:
Use the http URL in httpsProxy since both of the machines are on the same private network.
{ "proxies": { "default": { "httpProxy": "http://proxy_info:proxyPort", "httpsProxy": "http://proxy_info:proxyPort", "noProxy": "*.test.example.com,.example2.com" } } }