20230327--个人Docker镜像仓库管理
为了方便后续的DevOps流水线部署实践,构建一个常用的Docker镜像仓库。一个是基于私有网络Harbor,一个利用阿里云的个人免费服务。
一)Harbor个人Docker镜像仓库管理
1、Harbor中创建项目
登录Harbor--新建项目--输入项目名称、设置访问级别、设置存储容量等。
2、上传镜像
查看本地镜像
# docker image ls |grep slave
jenkins/slave latest 16a1f7a10608 20 months ago 467MB
jenkins/jnlp-slave latest 305b666795e8 21 months ago 467MB
确定镜像版本
# docker image inspect jenkins/slave|grep -i Version
"DockerVersion": "",
"JAVA_VERSION=jdk8u292-b10",
"Version": "4.10"
登录Harbor
Password:
WARNING! Your password will be stored unencrypted in /root/.docker/config.json.
Configure a credential helper to remove this warning. See
https://docs.docker.com/engine/reference/commandline/login/#credentials-store
Login Succeeded
镜像推送到Harbor
# docker tag jenkins/slave:latest harbor.local/devopstool/jenkins/slave:4.10
# docker push harbor.local/devopstool/jenkins/slave:4.10
3.任一环境获取镜像
由于选择的public的类型,应该任何环境都能下载
注:由于本Harbor证书为非第三方提供的通用证书,所以客户端还是添加https访问的证书,具体操作略
[root@k8s-master02 ~]# docker pull harbor.local/devopstool/jenkins/slave:4.10
4.10: Pulling from devopstool/jenkins/slave
627b765e08d1: Pull complete
a46f3468e2c0: Pull complete
cce0e932fca1: Pull complete
cf330ddf4bc1: Pull complete
c8264ba71815: Pull complete
7f85dc00fdb8: Pull complete
d48e8bf030d1: Pull complete
fc56e54019b3: Pull complete
4f4fb700ef54: Pull complete
Digest: sha256:1813916b9d553e656941120ab4a8a786219ceea0960948d61087a71895b3aeb4
Status: Downloaded newer image for harbor.local/devopstool/jenkins/slave:4.10
harbor.local/devopstool/jenkins/slave:4.10
[root@k8s-master02 ~]#
二)阿里云个人免费Docker镜像仓库管理
1.阿里云创建仓库
1)阿里云注册并登录容器镜像服务
2)选择个人版
3)创建命名空间:选择命名空间--创建命名空间
4)设置命名空间:默认仓库类型选择公开,自动创建仓库开启
2.上传镜像
本地docker服务器登录阿里云
# docker login --username=arrow003 registry.cn-beijing.aliyuncs.com
Password:
WARNING! Your password will be stored unencrypted in /root/.docker/config.json.
Configure a credential helper to remove this warning. See
https://docs.docker.com/engine/reference/commandline/login/#credentials-store
Login Succeeded
镜像推送到Registry
# docker tag jenkins/slave:latest registry.cn-beijing.aliyuncs.com/devopstool/slave:4.10
# docker push registry.cn-beijing.aliyuncs.com/devopstool/slave:4.10
确认上传的镜像
3.任一环境获取镜像
由于选择的public的类型,应该任何环境都能下载
[root@k8s-master02 ~]# docker pull registry.cn-beijing.aliyuncs.com/devopstool/kubectl:1.23.1-debian-10-r20
1.23.1-debian-10-r20: Pulling from devopstool/kubectl
0796bf144e3f: Pull complete
5ac39004dfb1: Pull complete
c65f2ceb8954: Pull complete
63a015e487d4: Pull complete
ecd02b208c7e: Pull complete
21bb094e8067: Pull complete
Digest: sha256:699415f2b11798abff3be546a69957ddf1e109732eac78bc8706d2c5702720cb
Status: Downloaded newer image for registry.cn-beijing.aliyuncs.com/devopstool/kubectl:1.23.1-debian-10-r20
registry.cn-beijing.aliyuncs.com/devopstool/kubectl:1.23.1-debian-10-r20
[root@k8s-master02 ~]#
参考URL
https://blog.csdn.net/Hello_World_QWP/article/details/84875235
https://blog.csdn.net/tgj891/article/details/126741322