- Create the Docker service plugin directory
sudo mkdir -p /etc/systemd/system/docker.service.d
- Create a file named http-proxy.conf
sudo touch /etc/systemd/system/docker.service.d/http-proxy.conf
- Edit the http-proxy.conf file
sudo vim /etc/systemd/system/docker.service.d/http-proxy.conf
- Write the content (replace the proxy IP and proxy port with your own)
[Service]
Environment="HTTP_PROXY=socks5://127.0.0.1:1080" "HTTPS_PROXY=socks5://127.0.0.1:1080" "NO_PROXY=localhost,127.0.0.1,docker-registry.somecorporation.com"
- Reload the service program's configuration file
sudo systemctl daemon-reload
- Restart Docker
sudo systemctl restart docker
- Verify if the configuration was successful
systemctl show --property=Environment docker
At this point, Docker can pull files from the specified proxy.
Additionally, if you need to use an HTTP proxy, simply replace socks5 with http.