How to configure docker container proxy?

You can set the proxy environment variables when starting the container, for example:

docker container run \
  -e HTTP_PROXY=http://username:[email protected] \
  -e HTTPS_PROXY=http://username:[email protected] \
  myimage

If you want the proxy-server to be automatically used when starting a container, you can configure default proxy-servers in the Docker CLI configuration file (~/.docker/config.json). You can find instructions for this in the networking section in the user guide.

For example:

{
  "proxies": {
    "default": {
      "httpProxy": "http://username:[email protected]",
      "httpsProxy": "http://username:[email protected]"
    }
  }
}

To verify if the ~/.docker/config.json configuration is working, start a container and print its env:

docker container run --rm busybox env

PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
HOSTNAME=220e4df13604
HTTP_PROXY=http://username:[email protected]
http_proxy=http://username:[email protected]
HTTPS_PROXY=http://username:[email protected]
https_proxy=http://username:[email protected]
HOME=/root

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)