Skip to content

Instantly share code, notes, and snippets.

@nanusdad
Last active December 12, 2023 06:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nanusdad/cb0adc76b594363184e7067aeef26787 to your computer and use it in GitHub Desktop.
Save nanusdad/cb0adc76b594363184e7067aeef26787 to your computer and use it in GitHub Desktop.
Docker configuration behind HTTP or HTTPS proxy

Docker configuration behind HTTP or HTTPS proxy

Create http-proxy configuration file

sudo mkdir -p /etc/systemd/system/docker.service.d
sudo vi /etc/systemd/system/docker.service.d/http-proxy.conf

Add lines similar to the ones below and save file

[Service]
Environment="HTTP_PROXY=http://proxy.example.com:3128"
Environment="HTTPS_PROXY=https://proxy.example.com:3129"
Environment="NO_PROXY=localhost,127.0.0.1,docker-registry.example.com,.corp" #if needed

Flush changes and restart Docker

sudo systemctl daemon-reload
sudo systemctl restart docker

Verify the configuration

sudo systemctl show --property=Environment docker

Output should be something similar to -

Environment=HTTP_PROXY=http://proxy.example.com:3128 HTTPS_PROXY=https://proxy.example.com:3129 NO_PROXY=localhost,127.0.0.1,docker-registry.example.com,.corp

Read more at Docker Documentation website.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment