Unable to pull images from docker hub in your environment ?

A couple of days back I faced an issue where I was able to pull images from docker hub on my laptop when connecting from my home and same was failing when connecting in office. I tried setting a proxy on my RHEL OS with "export" env setting but still, it didn't work. Then after googling figured out the exact root cause.

Setting up proxy on OS environment (using export with RHEL) is not enough in case of docker, here you need to set proxy on one more level i.e. on docker settings. To do this follow the below steps:

Create a new file "http-proxy.conf" if not exists in the below folder with shown contents:

[root@localhost ~]# vi /etc/systemd/system/docker.service.d/http-proxy.conf

[Service]
Environment="HTTP_PROXY=http://proxy1.localnet.net:8080/"
Environment="HTTPS_PROXY=http://proxy1.localnet.net:8080/"

save and quit.


Restart docker service:
[root@localhost ~]# systemctl daemon-reload

[root@localhost ~]# systemctl restart docker


Verify if proxy is configured in docker settings:

[root@localhost ~]# docker info
.
.
.
HTTP Proxy: http://proxy1.localnet.net:8080/
HTTPS Proxy: http://proxy1.localnet.net:8080/
.
.
.

[root@localhost yum.repos.d]# systemctl show --property Environment docker
Environment=HTTP_PROXY=http://proxy1.localnet.net:8080/ HTTPS_PROXY=http://proxy1.localnet.net:8080/

Try pulling image from docker hub, not it should work fine.

Comments

Post a Comment

Popular posts from this blog

Recover or restore initramfs file in RHEL or CentOS 7

Space reclamation / UNMAP on RHEL or CentOS 7

How to recover /boot partition on RHEL or CentOS 7?