Configure Proxy for Docker

Next, configure proxy for Docker. The Docker daemon uses the HTTP_PROXY, HTTPS_PROXY, and NO_PROXY environmental variables in its start-up environment to configure HTTP or HTTPS proxy behavior.

To configure proxy for Docker:

  1. Create a systemd drop-in directory for the docker service:

    $ sudo mkdir -p /etc/systemd/system/docker.service.d
  2. Create a file called /etc/systemd/system/docker.service.d/http-proxy.conf that adds the HTTP_PROXY environment variable:

    Environment="HTTP_PROXY=http://nibr1:3128/"  "NO_PROXY=localhost,,nibr1,nibr2.nibr3"
    Environment="HTTPS_PROXY=http://nibr1:3128/" "NO_PROXY=localhost,,nibr1,nibr2,nibr3"
  3. Flush changes using the Flush Changes command.

    Flush Changes Command:

    $ sudo systemctl daemon-reload
  4. Restart Docker using the Restart Docker command.

    Restart Docker Command:

    $ sudo systemctl restart docker
  5. After Docker restarts, verify that the configuration loaded using the Verify Configuration command.

    Verify Configuration Command:

    $ systemctl show --property=Environment docker