[iyunv@localhost docker]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
repos_local/zookeeper 0.0.1 bdb481b4f17a 2 days ago 541.5 MB
repos_local/zookeeper 是上篇博文介绍的使用Dockerfile文件创建的镜像, 重命名
docker tag repos_local/zookeeper:0.0.1 192.168.199.131/repos_local/zookeeper:latest
docker tag 原镜像名:tag 新镜像名:tag
docker images 查看镜像名称是否更改正确
[iyunv@localhost docker]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
192.168.199.131/repos_local/zookeeper latest bdb481b4f17a 2 days ago 541.5 MB ## 推送镜像
docker push 192.168.199.131/repos_local/zookeeper:latest
如果提示以下错误, 说明没有把搭建的registry加入可信任的列表里面, 如果有https域名或者能创建.crt证书, 那么可以忽略以下步骤
Error response from daemon: invalid registry endpoint https://192.168.199.131/v0/: unable to ping registry endpoint https://192.168.199.131/v0/
v2 ping attempt failed with error: Get https://192.168.199.131/v2/: dial tcp 192.168.199.131:443: no route to host
v1 ping attempt failed with error: Get https://192.168.199.131/v1/_ping: dial tcp 192.168.199.131:443: no route to host. If this private registry supports only HTTP or HTTPS with an unknown CA certificate, please add `--insecure-registry 192.168.199.131` to the daemon's arguments. In the case of HTTPS, if you have access to the registry's CA certificate, no need for the flag; simply place the CA certificate at /etc/docker/certs.d/192.168.199.131/ca.crt
解决方法:
只针对centos7下 Docker version 1.12.5, build 047e51b/1.12.5版本有效, 其它版本没做过测试
vi /etc/sysconfig/docker
注意--insecure-registry 192.168.199.131插入的位置
# Modify these options if you want to change the way the docker daemon runs
OPTIONS='--selinux-enabled --log-driver=journald --signature-verification=false --insecure-registry 192.168.199.131'
if [ -z "${DOCKER_CERT_PATH}" ]; then
DOCKER_CERT_PATH=/etc/docker
fi
重启docker服务
systemctl restart docker.service
重新执行docker push 192.168.199.131/repos_local/zookeeper:latest , 这次应该就能成功了 ## 查看镜像仓库