How to set the Proxy for Docker in Linux

Systemd Docker Service

In order to the set the proxy for Docker, you will need to create a configuration file for the Docker service. No configuration files exist by default, so one will have to be created.

All Systemd service configuration are stored under /etc/systemd/system. In order to keep things organized, we can create a child directory docker.service.d, rather than creating a file called /etc/systemd/system/docker.service.

Within this configuration file, we can set our HTTP and HTTPS proxy. We can also set our NO_PROXY value, too.

Creating Proxy Configuration

  1. Create a new directory for our Docker service configurations.
sudo mkdir -p /etc/systemd/system/docker.service.d

2. Create a file called proxy.conf in our configuration directory.

sudo vi /etc/systemd/system/docker.service.d/proxy.conf

3. Add the following contents, changing the values to match your environment.


4. Save your changes and exit the text editor.

5. Reload the daemon configuration.

sudo systemctl daemon-reload

6. Restart Docker to apply our changes.

sudo systemctl restart docker.service

7. To check Proxy is added or not use the following command

docker info | grep Proxy

8. After the service is restarted Docker should be able to pull images from external repositories. You can test this by attempting to pull down an image. If the download completes and does not timeout, your proxy settings have been applied.

9. Enjoy



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store