Docker & Ubuntu Proxy
Setting Up a System-Wide Proxy on Ubuntu
To configure proxy settings that apply to all users, shells and services on an Ubuntu host, add environment variables in one of the following locations.
1. Edit /etc/environment
/etc/environment
Open the file with root privileges:
Add the proxy definitions (customize host, port and no-proxy list as required):
Save and exit (in nano: Ctrl+O, Enter, Ctrl+X).
Apply changes immediately by running:
Otherwise, the settings will take effect at the next login.
2. Create a Shell Profile Script
An alternative approach uses /etc/profile.d/
to export variables for all interactive and non-interactive shells.
Create the script file:
Insert the following content:
Make the script executable:
Reload the profile or log in again:
3. Configure APT to Use the Proxy
To ensure that apt-get
and related tools honor the proxy:
Open or create an APT configuration snippet:
Add the following lines:
Save, exit and test with:
Setting Up a Proxy for Docker
Docker’s daemon and build processes require their own proxy configuration when managed by systemd.
Create the systemd drop-in directory if it does not already exist:
Create or edit the proxy configuration file:
Add the following content, adapting values as needed:
Reload systemd and restart Docker to apply the new settings:
Verify that the environment variables are active:
Last updated