Wednesday, February 14, 2018

Linux command line proxy / docker proxy configuraiton

Linux command line proxy configuration 

 If your system  placed in the restricted network and it  require to connect Internet through proxy server then you need to setup proxy server configuration by exporting http_proxy  or https_proxy linux environment value.

syntax :

export http_proxy=http://username:password@proxyserver:proxyport

export https_proxy=https://username:password@proxyserver:proxyport

example:

export http_proxy=http://kamal:kamal@myproxy.mynetwork.com:8080

export https_proxy=http://kamal:kamal@myproxy.mynetwork.com:8443

if you want to revert http_proxy config then simply type  $unset http_proxy from linux command prompt .

Docker proxy configuration

Same way you need to setup proxy configuration for docker too so that you can download / search / push / pull docker images from public docker registry.

by default docker wont take proxy config from environment variable you need to config by creating http-proxy.config file in the docker service directory.

1) Create a directory path and config file as a root user ( remember your user need to be a member of docker group or you must be a root user to perform this docker config by default directory and configuration file doesn't exist  )

# mkdir -p /etc/systemd/system/docker.service.d

vi /etc/systemd/system/docker.service.d/http-proxy.conf    or      #vi /etc/systemd/system/docker.service.d/https-proxy.conf

2) Edit docker proxy  config file
  
#vi /etc/systemd/system/docker.service.d/https-proxy.conf
[Service]
Environment="HTTP_PROXY=http://kamal:durai@proxy.myserver.com:8080"

3)Reload systems daemon configurations

 #systemctl daemon-reload

4) Restart docker service
  #systemctl restart docker
  
5) Verify docker proxy config
  #systemctl show --property=Environment docker    

6) Search docker images from docker registry 

#docker search nginx 

now you can see number of  nginx docker iamges from varies registry