root@ubuntu:# uname -a Linux ubuntu 4.4.0-116-generic #140-Ubuntu SMP Mon Feb 12 21:23:04 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
1、如果dockerhub的https证书是非权威机构的需要执行,需要添加证书信任
root@ubuntu:# echo -n | openssl s_client -showcerts -connect dockerhub.xx.com:443 2>/dev/null | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' >> /etc/ssl/certs/dockerhub.xx.com.crt
root@ubuntu:# update-ca-certificates
2、修改/etc/docker/daemon.json
root@ubuntu:# cat /etc/docker/daemon.json
{
"insecure-registries": ["dockerhub.xx.com:5000"],
"registry-mirrors": ["https://dockerhub.xx.com"]
}
root@ubuntu:# service docker restart
3、通过 docker tag重命名镜像,使之与registry匹配
root@ubuntu:# docker tag ubuntu:16.04 dockerhub.xx.com/xxx/ubuntu:16.04
4、登入dcokerhub,登入一次就可以
root@restart:# docker login dockerhub.xx.com
5、上传镜像
docker push dockerhub.xx.com/xxx/ubuntu:16.04
参考:
https://www.cnblogs.com/Javame/p/7389093.html