Configuring proxy in Docker

A proxy is required when the server running on Docker does not have direct access to the Internet.

Configure the Docker daemon to use a proxy server to access Docker images stored in the official Docker Hub Registry or any other registries.

We simply need to set the http_proxy and https_proxy environmental variables during build time. We can do this with the docker build command itself.

$ sudo docker build -t curl --build-arg http_proxy=http://192.168.33.10:3128 .

Or we can specify the http_proxy value using the ENV instruction within the Dockerfile.

#Dockerfile
FROM ubuntu

ENV http_proxy "http://192.168.80.10:3333"
ENV https_proxy "http://192.168.80.10:3333"

re-run the build.

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s