Skip to main content
Skip table of contents

Set-up proxy settings in CentOS and Docker Installation

This document will guide you through that how you can set-up proxy settings in CentOS and then install Docker Engine so you can deploy the solution. 
We will go through the following steps in order to get the internet access if you are behind a proxy server.

  1. Update the /etc/yum.conf with the proxy URL and port for the libraries of CentOS to be updated.
  2. In the docker installation step, export the https_proxy variable in the shell environment to enable pip to download docker-compose.
  3. After the docker is installed, we need to create config file with the proxy server information in it in order to enable the docker engine to pull images over the internet.

A VM running CentOS is required which is behind the proxy server.

Proxy server URL, port, and Authentication details are needed.

Update yum.conf 

Edit the /etc/yum.conf yum configuration file and specify the following proxy settings in the main section.


Remove the proxy_username and proxy_password if the proxy server does not require any authentication.

Exporting Proxy detail to shell

Now, we need to export the Proxy details to CentOS shell which will be utilized by pip when we will be installing docker-compose. 

export http_proxy="http://<insert_username>:<insert_password>"
export https_proxy="https://<insert_username>:<insert_password>"

if there is no authentication at the proxy server, please run the following commands instead of the above.

export http_proxy=""
export https_proxy=""

Install Docker Engine and Docker-Compose

After we have made the above changes, we need to install docker engine and docker-compose on CentOS. For that purpose, run the following commands one by one:

yum install -y epel-release git tcpdump sysstat lsof curl wget strace htop telnet strace  screen iotop whois netcat lsof net-tools ncdu nmap nethogs iftop open-vm-tools.x86_64  open-vm-tools-desktop.x86_64 open-vm-tools-devel.x86_64 open-vm-tools-test.x86_64
yum install -y sudo yum-utils
yum-config-manager --add-repo -y
yum install -y docker-ce
systemctl enable docker.service
systemctl start docker.service
yum install -y python-pip
pip install --upgrade pip
pip install docker-compose

Setting Up proxy for Docker and Docker-Compose

To set up proxy for docker engine, we need to create the /etc/systemd/system/docker.service.d directory. and then create a service config file in the docker.service.d directory with name http-proxy.conf.

mkdir /etc/systemd/system/docker.service.d
touch /etc/systemd/system/docker.service.d/http-proxy.conf

Alter the following text according to your requirement and then put it in newly created file.

 # NO_PROXY is optional and can be removed if not needed
 # Change proxy_url to your proxy IP or FQDN and proxy_port to your proxy port
 # For Proxy server which require username and password authentication, just add the proper username and password to the URL. (see example below)

 # Example without authentication
 Environment="HTTP_PROXY=http://proxy_url:proxy_port" "NO_PROXY=localhost,"

 # Example with authentication
 Environment="HTTP_PROXY=http://username:password@proxy_url:proxy_port" "NO_PROXY=localhost,"

Reload systemctl so that new settings are read

sudo systemctl daemon-reload

Verify that docker service environment is properly set

sudo systemctl show docker --property Environment

Restart docker service so that it uses updated Environment settings.

sudo systemctl restart docker

That's it!. Now you have running docker environment on CentOS with proxy settings enabled.

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.