-->

Monday, January 31, 2022

[ Solved ] http: server gave HTTP response to HTTPS client

Issue:- 

The issue occured if you are using the private repository provided by the Docker hub via container on a private server and pushing the image using the IP of the server directly. 

 Error:- 

[centos@docker ~]$ docker push 172.31.14.46:5000/dev
Using default tag: latest
The push refers to repository [172.31.14.46:5000/dev]
Get "https://172.31.14.46:5000/v2/": http: server gave HTTP response to HTTPS client
Due to the above error the image is not getting pushed into the Repository.

Resolution:-

The issue is coming because docker is expecting you to use the SSL certificate while you using the non-secured http call due to which it's giving you the error.

To resolve this issue you need to update the docker daemon to allow the communication over the HTTP which is like a security flaw and you yourself are accepting it from the docker daemon perspective. It can be done as follows

[root@docker ~]# vi /etc/docker/daemon.json
{ "insecure-registries":["172.31.14.46:5000"] }

[root@docker ~]# systemctl restart docker

[root@docker ~]# su - centos

[centos@docker ~]$ docker push 172.31.14.46:5000/dev Using default tag: latest The push refers to repository [172.31.14.46:5000/dev] 40a154bd3352: Pushed latest: digest: sha256:81d5a9161533bba27b2fcc6475228ff2348c82f7bb610bcd97880a100f8e4d5c size: 529

[centos@docker ~]$ curl 172.31.14.46:5000/v2/_catalog {"repositories":["dev"]}

As shown above after allowing the insecured-registries in the /etc/docker/daemon.json and restarting the docker service solves the issue.

Other way can be to use the Loadbalancer and offloading the SSL certificate at the Loadbalancer than also it should work fine with the HTTPS call.

0 comments:

Post a Comment