Proxy Settings For Docker And Nix Daemons
Docker Daemon Proxy
The Docker daemon checks environment variables in its startup environment.
According to the official Docker documentation
Create a directory and configuration file for the Docker service:
1 | sudo mkdir -p /etc/systemd/system/docker.service.d/ |
Create
/etc/systemd/system/docker.service.d/http-proxy.conf with
your proxy settings:
1 | [Service] |
HTTPS_PROXY selects a proxy for HTTPS destinations; its
URL scheme describes the connection to the proxy. An HTTP CONNECT proxy
normally uses http:// for both variables. Use
https://proxy.example.com:3129 only when that proxy
endpoint itself supports TLS. Put comments on their own lines, not after
Environment= assignments. Restarting Docker can interrupt
running containers; plan the restart for your host.
Apply the configuration changes:
1 | sudo systemctl daemon-reload |
Check that the environment variables are properly set:
1 | sudo systemctl show --property=Environment docker |
Nix Daemon Proxy
According to the Nixos CN documentation
The /run drop-in below is temporary and disappears at
reboot. On a non-NixOS systemd installation, use
/etc/systemd/system/nix-daemon.service.d/override.conf for
a persistent drop-in instead (create that directory first). On NixOS,
prefer systemd.services.nix-daemon.environment.https_proxy
in the declarative configuration and rebuild through your normal
workflow; do not treat the runtime drop-in as persistent configuration.
The SOCKS example requires a SOCKS endpoint at that port and support in
the installed Nix HTTP transport.
1 | sudo mkdir -p /run/systemd/system/nix-daemon.service.d/ |
Create
/run/systemd/system/nix-daemon.service.d/override.conf with
your proxy settings:
1 | sudo tee /run/systemd/system/nix-daemon.service.d/override.conf << EOF |
Apply the configuration changes:
1 | sudo systemctl daemon-reload |
PS
- The
NO_PROXYvariable should include local addresses and internal services that shouldn't go through the proxy - Different proxy protocols may be required (HTTP, HTTPS, SOCKS5) depending on your network setup