received unexpected HTTP status: 500 Internal Server Error:docker push 报错解决

前言:在EC2 CentOS7上使用docker 搭建了一个私有仓库,在使用过程中遇到的问题进行总结:

公网IP:34.222.114.8

私网IP:10.0.1.46

问题①:

[root@ip-10-0-1-46 ~]# docker push 34.222.114.8:5000/centos:v1 

The push refers to a repository [34.222.114.8:5000/centos]

Get https://34.222.114.8:5000/v1/_ping:http:server gave HTTP response to HTTPS client

 出现这个问题的原因主要是docker从1.3.2版本开始与docker registry交互默认使用的是HTTPS,而docker harbor默认是HTTP方式,这时候使用push等命令时就会报错!

解决:

修改配置文件,添加私有仓库地址(可以配置多个)

[root@ip-10-0-1-46 ~]# vi /etc/docker/daemon.json 

{
  "insecure-registries": [ "34.222.114.8:5000" ]
}

insecure-registries:不安全的仓库地址,如果没有配置https证书,那么需要将私有仓库的地址配置到这里

重启docker,重新加载配置文件

[root@ip-10-0-1-46 ~]# systemctl restart docker;systemctl daemon-reload

 问题②:

[root@ip-10-0-1-46 ~]# docker push 34.222.114.8:5000/hello-world:v2
The push refers to a repository [34.222.114.8:5000/hello-world]
e07ee1baac5f: Retrying in 1 second 
received unexpected HTTP status: 500 Internal Server Error.

将镜像推送到私有仓库的时候,报错“received unexpected HTTP status: 500 Internal Server Error”;是由于selinux未关闭导致docker出现异常情况

解决

关闭selinux

临时关闭

[root@ip-10-0-1-46 ~]# setenforce 0

或永久关闭
[root@ip-10-0-1-46 ~]# sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config

重新push

[root@ip-10-0-1-46 ~]# docker push 34.222.114.8:5000/hello-world:v2
The push refers to a repository [34.222.114.8:5000/hello-world]
e07ee1baac5f: Pushed 
v2: digest: sha256:f54a58bc1aac5ea1a25d796ae155dc228b3f0e11d046ae276b39c4bf2f13d8c4 size: 525

获取仓库中所有镜像

[root@ip-10-0-1-46 ~]# curl 34.222.114.8:5000/v2/_catalog
{"repositories":["centos","hello-world"]}

 获取仓库中指定镜像

curl  http://仓库地址/v2/镜像名称/tags/list

[root@ip-10-0-1-46 ~]# curl 34.222.114.8:5000/v2/centos/tags/list
{"name":"centos","tags":["7"]}

技术性分享,转载请注明出处!

欢迎互相交流,共同进步!

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值