阿里云私有镜像仓

地址: https://cr.console.aliyun.com/cn-shenzhen/instances/repositories

过程很简单, 首先申请开通阿里云私有镜像仓, 然后使用此账号登录即可, 比如:

  1. $ docker login --username=xxx@qq.com registry.cn-shenzhen.aliyuncs.com

然后创建一个命名空间:
📃 私有仓库的搭建 - 图1

将本地的镜像重新打标签并上传即可, 比如:

  1. docker tag [ImageId] registry.cn-shenzhen.aliyuncs.com/quanzaiyu/kubernetes-dashboard-amd64:[镜像版本号]
  2. docker push registry.cn-shenzhen.aliyuncs.com/quanzaiyu/kubernetes-dashboard-amd64:[镜像版本号]

同时, 还可以使用镜像加速服务:
📃 私有仓库的搭建 - 图2

上传到私有仓库的镜像:
📃 私有仓库的搭建 - 图3

Registry

Docker 注册服务器

下载 registry 镜像, 并创建容器

  1. $ docker pull registry # 下载Docker注册服务器镜像
  2. $ docker run -d \
  3. -p 5000:5000 \
  4. --name server-registry \
  5. -v /tmp/registry:/tmp/registry \
  6. registry # 运行Docker注册服务器

将私有仓库上传到Docker注册服务器

首先,得对需要上传的镜像打标签,并指定Docker注册服务器的地址

  1. docker tag centos:latest localhost:5000/centos:1.0

然后,将打了标签的镜像上传到Docker注册服务器:

  1. $ docker push localhost:5000/centos:1.0
  2. The push refers to a repository [localhost:5000/centos]
  3. f972d139738d: Pushed
  4. 1.0: digest: sha256:dc29e2bcceac52af0f01300402f5e756cc8c44a310867f6b94f5f7271d4f3fec size: 529

注意,这里由于是在一台机子上演示的,所以意义不大,通常我们会在另一台机器上开一个Docker注册服务器。将镜像上传到另一个机器上, 这里的 localhost:5000 就是另一台机器的镜像仓库地址。

拉取私有仓库镜像

  1. $ docker pull localhost:5000/centos:1.0
  2. Trying to pull repository localhost:5000/centos ...
  3. 1.0: Pulling from localhost:5000/centos
  4. Digest: sha256:dc29e2bcceac52af0f01300402f5e756cc8c44a310867f6b94f5f7271d4f3fec
  5. Status: Image is up to date for localhost:5000/centos:1.0
  6. # 如果没有指定标签,而指定镜像又没有latest标签,则报错
  7. $ docker pull localhost:5000/centos
  8. Using default tag: latest
  9. Trying to pull repository localhost:5000/centos ...
  10. Pulling repository localhost:5000/centos
  11. Error: image centos:latest not found

Harbor

参考资料