using docker with proxy
- Create the drop-in directory:bash
sudo mkdir -p /etc/systemd/system/docker.service.dUse code with caution. - Create the proxy configuration file:
Create a file named/etc/systemd/system/docker.service.d/http-proxy.conf. - Add your proxy details:
Paste the following into the file, replacing the placeholder URLs with your actual proxy address:ini[Service] Environment="HTTP_PROXY=http://proxy.example.com:3128" Environment="HTTPS_PROXY=http://example.com" Environment="NO_PROXY=localhost,127.0.0.1,docker-registry.example.com"Use code with caution. - Apply the changes:
Reload the systemd manager configuration and restart the Docker service:bashsudo systemctl daemon-reload sudo systemctl restart dockerUse code with caution. - Verify the configuration:
Check if the environment variables are active:bashsudo systemctl show --property=Environment dockerUse code with caution.
2. Configure the Docker Client (Containers & Builds)
This
configuration tells Docker to automatically inject proxy environment
variables into any new container you run or any image you build.
- Edit the user config file:
Open (or create)~/.docker/config.jsonin your home directory. - Add the
proxiesblock:
Ensure the structure looks like this:json{ "proxies": { "default": { "httpProxy": "http://proxy.example.com:3128", "httpsProxy": "http://example.com", "noProxy": "localhost,127.0.0.1" } } }Use code with caution.
Comments
Post a Comment