How to Configure Docker HTTP Proxy to Retrieve Images in CentOS/RHEL 7 and 8

There are different locations where proxy configuration can be changed. In latest Docker distribution, it uses systemd to run and configure Docker. This post provides the steps to Docker HTTP Proxy Configuration when you don’t have direct access to the Internet.

Configuring Docker HTTP proxy using systemd

1. Edit /etc/systemd/system/docker.service.d/docker-sysconfig.conf and append the below lines:

# vi /etc/systemd/system/docker.service.d/docker-sysconfig.conf

2. Reload the Docker daemon and check if proxy is successfully configured. Then restart docker service:

# systemctl daemon-reload

Verify the systemd property for “environment” for the docker service:

# systemctl show --property=Environment docker
Environment=HTTP_PROXY=[your.proxy.server]:[port] HTTPS_PROXY=[your.proxy.server]:[port]

Restart the docker deamon for the changes to come into effect:

# systemctl restart docker

3. Login into the Container Registry to test the settings we have done:

# docker login
Username: [username]
Password: [password]

WARNING! Your password will be stored unencrypted in /root/.docker/config.json.
Configure a credential helper to remove this warning. See
Login Succeeded