Docker_Proxy_Setting_container
The proxy setting in Docker
Add proxy information in below files in docker and restart docker service.
in this example, http://172.26.XX.X:8080 and https://172.26.XX.X:8080 is the proxy server to access internet without any user_name and password.
[root@rhel7 ~]# cat /etc/sysconfig/docker . . HTTP_PROXY="http://172.26.XX.X:8080" HTTP_PROXY="http://172.26.XX.X:8080" . . [root@rhel7 ~]# systemctl restart docker
Or we can add this setting in systemd also
[root@feenixdv ~]# mkdir -p /etc/systemd/system/docker.service.d/ [root@feenixdv ~]# cat /etc/systemd/system/docker.service.d/http-proxy.conf [Service] Environment="HTTP_PROXY=http://172.26.25.4:8080/" [root@localhost ~]# systemctl daemon-reload [root@localhost ~]# systemctl restart docker
Now check with pull.
[root@rhel7 ~]# docker pull centos Using default tag: latest Trying to pull repository docker.io/library/centos ... latest: Pulling from docker.io/library/centos 256b176beaff: Pull complete Digest: sha256:6f6d986d425aeabdc3a02cb61c02abb2e78e57357e92417d6d58332856024faf [root@rhel7 ~]# docker images REPOSITORY TAG IMAGE ID CREATED SIZE docker.io/centos latest 5182e96772bf 6 weeks ago 199.7 MB
Proxy setting in container after login
same for container. First loing and then set environment variable. we can also put into "bashrc or bash_profile"
[root@rhel7 ~]# docker run -it docker.io/centos install package [root@7457ade046bf yum.repos.d]# export http_proxy="http://172.26.XX.XX:8080" [root@7457ade046bf yum.repos.d]# export https_proxy="http://172.26.XX.X:8080" [root@7457ade046bf yum.repos.d]# yum install httpd Loaded plugins: fastestmirror, ovl Loading mirror speeds from cached hostfile * extras: centos.excellmedia.net * updates: centos.excellmedia.ne 2/6 Verifying : apr-util-1.5.2-6.el7.x86_64 3/6 Verifying : httpd-2.4.6-80.el7.centos.1.x86_64 4/6 Verifying : apr-1.4.8-3.el7_4.1.x86_64 5/6 Verifying : centos-logos-70.0.6-3.el7.centos.noarch 6/6 Installed: httpd.x86_64 0:2.4.6-80.el7.centos.1 Dependency Installed: apr.x86_64 0:1.4.8-3.el7_4.1 apr-util.x86_64 0:1.5.2-6.el7 centos-logos.noarch 0:70.0.6-3.el7.centos httpd-tools.x86_64 0:2.4.6-80.el7.centos.1 mailcap.noarch 0:2.1.41-2.el7 Complete!