Docker - 阿里云仓库

0.0.准备工作

  • 在阿里云上开通"容器镜像服务"

0.1.占位符解释

😂


{
"{YourNamespace}":"阿里云容器镜像服务中的命名空间,具体位置 → 阿里云 / 容器镜像服务 / 实例列表 / 镜像仓库 / 仓库管理 / 命名空间",
"{YourRepoName}":"阿里云容器镜像服务中的镜像仓库,具体位置 → 阿里云 / 容器镜像服务 / 实例列表 / 镜像仓库 / 仓库管理 / 镜像仓库",
}

1.登录阿里云Docker Registry


$ docker login --username=username@aliyun registry.aliyuncs.com

Password:
WARNING! Your password will be stored unencrypted in /home/username/.docker/config.json.
Configure a credential helper to remove this warning. See
https://docs.docker.com/engine/reference/commandline/login/#credentials-store

2.将镜像推送到Registry


#[ImageId]就是你服务器上的镜像的Id , 可以先使用"docker images"查询一下要推送的镜像Id
#标记本地镜像 , 将其归入阿里云Docker仓库 .
$ docker tag [ImageId] registry.aliyuncs.com/{YourNamespace}/{YourRepoName}:latest

#将本地的镜像上传到镜像仓库 , 要先登陆到镜像仓库 .
$ docker push registry.aliyuncs.com/{YourNamespace}/{YourRepoName}:latest

#以下为输出内容 . . . 
The push refers to repository [registry.aliyuncs.com/{YourNamespace}/test]
xxxxxxxxxxxx: Pushed
xxxxxxxxxxxx: Pushed
xxxxxxxxxxxx: Pushed
xxxxxxxxxxxx: Pushed
xxxxxxxxxxxx: Pushed
xxxxxxxxxxxx: Pushed
xxxxxxxxxxxx: Pushed
xxxxxxxxxxxx: Pushed
xxxxxxxxxxxx: Pushed
xxxxxxxxxxxx: Pushed
latest: digest: sha256:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx size: 2420

3.从阿里云Docker容器中拉取镜像

#如果仓库类型为"私有"的话,需要先登录,否则报错 . 
$ docker pull registry.aliyuncs.com/{YourNamespace}/{YourRepoName}:latest

#以下为输出内容 . . . 
Error response from daemon: pull access denied for registry.aliyuncs.com/{YourNamespace}/test, repository does not exist or may require 'docker login': denied: requested access to the resource is denied

#如果仓库类型为"私有"的话,登录之后 , 再次拉取
$ docker pull registry.aliyuncs.com/{YourNamespace}/{YourRepoName}:latest

#以下为输出内容 . . . 
latest: Pulling from {YourNamespace}/test
xxxxxxxxxxxx: Pull complete
xxxxxxxxxxxx: Pull complete
xxxxxxxxxxxx: Pull complete
xxxxxxxxxxxx: Pull complete
xxxxxxxxxxxx: Pull complete
xxxxxxxxxxxx: Pull complete
xxxxxxxxxxxx: Pull complete
xxxxxxxxxxxx: Pull complete
xxxxxxxxxxxx: Pull complete
xxxxxxxxxxxx: Pull complete
Digest: sha256:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Status: Downloaded newer image for registry.aliyuncs.com/{YourNamespace}/{YourRepoName}:latest
registry.aliyuncs.com/{YourNamespace}/{YourRepoName}:latest
posted @ 2021-11-25 14:11  zh89233  阅读(1297)  评论(0编辑  收藏  举报