docker镜像仓库对于docker应用来说是必不可少的
1、使用docker hub也是一个选项,但是国外的地址对于我们来说存在比较慢的问题
2、使用阿里云的docker仓库,结果发现2020年3月已经收费了
总的来说,就搭建一个私有化的docker仓库是需要的,下面介绍部署私有化仓库的步骤:
1、使用registry 镜像创建私有仓库
docker run -d -p 5000:5000 registry:2
如果5000端口被占用,请使用其他端口
2、配置ssl证书启用https
对于高版本的docker,必须使用https,否则docker push会报错
申请免费ssl证书请参照博客 https://blog.csdn.net/bowei026/article/details/89197879
如果nginx没有ssl模块,请参照博客 https://blog.csdn.net/bowei026/article/details/88019214
3、管理私有仓库
docker images 查看本地的镜像
docker tag ubuntu:18.04 docker.test.com/mylinux 将ubuntu:18.04打上标签
docker push docker.test.com/mylinux 推送到私有仓库
curl https://docker.test.com/v2/_catalog 查看私有仓库中的镜像
返回: {"repositories":["mylinux"]}
4、从私有仓库中pull镜像
docker pull docker.test.com/mylinux
# docker pull docker.test.com/mylinux
Using default tag: latest
latest: Pulling from mylinux
35c102085707: Pull complete
251f5509d51d: Pull complete
8e829fe70a46: Pull complete
6001e1789921: Pull complete
Digest: sha256:ca013ac5c09f9a9f6db8370c1b759a29fe997d64d6591e9a75b71748858f7da0
Status: Downloaded newer image for docker.test.com/mylinux:latest
docker.coolgua.com/mylinux:latest
# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
ubuntu latest 1d622ef86b13 3 weeks ago 73.9MB
docker.coolgua.com/mylinux latest a2a15febcdf3 9 months ago 64.2MB
本文内容到此结束。