本文只要介绍本地docker镜像与阿里云镜像仓库的使用,本地创建镜像,上传到阿里云,
一、获取阿里云镜像加速器地址
注册一个阿里云账号,登录,找到右上边的控制台
在界面左侧,找到产品与服务--》 搜索 容器镜像服务
点开 下面的 容器镜像服务
则,每个账号都存在一个独立的加速器地址,根据下面的操作问题可 修改本地daemon.json , 然后重启docker
二、docker 登录阿里云仓库并push镜像
获取带 加速地址后,先在 阿里云上创建 命名空间 和仓库。 阿里云的远程镜像格式一般采用如下:
远程地址/【命名空间】/【仓库地址】: 镜像版本
2.1 创建命名空间
2.2 创建仓库
选择 自己创建的命名空间, 创建完成后,点击左侧的 镜像仓库和命名空间 就可查看刚才创建的仓库
那和如何 查找仓库的具体网络地址呢, 点击 镜像仓库 -》 管理
然会看,基本信息的 公网地址,即为仓库的地址, 在push镜像时,我们需要将本地的镜像打上 与该地址一致的 标签。页面上有关于 如何上传 拉取镜像的操作
三、本地docker push镜像到阿里云
进入本地docker环境, 登录到阿里云. 使用自己的用户名与密码
[root@localhost ~]# docker login --username=XXX registry.cn-hangzhou.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
[root@localhost ~]#
将需要上传的 镜像 先打上 与容器一致的地址,
[root@localhost ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
ubuntu/centos/nvidia 16.04-3.1.0-cuda9 209178ecd5af 5 hours ago 348MB
registry.cn-hangzhou.aliyuncs.com/ubuntu_centos_cuda/nvidia 16.04-3.1.0-cuda9 209178ecd5af 5 hours ago 348MB
然会 docker push 仓库名:标签 上传镜像
[root@localhost ~]# docker push registry.cn-hangzhou.aliyuncs.com/ubuntu_centos_cuda/nvidia:16.04-3.1.0-cuda9
The push refers to repository [registry.cn-hangzhou.aliyuncs.com/ubuntu_centos_cuda/nvidia]
95463e2c5a3e: Layer already exists
621c51016399: Layer already exists
145eb658aaf0: Layer already exists
e6c3a9c7c79e: Layer already exists
f1dfa8049aa6: Layer already exists
79109c0f8a0b: Layer already exists
33db8ccd260b: Layer already exists
b8c891f0ffec: Layer already exists
16.04-3.1.0-cuda9: digest: sha256:d21c7a8ff28d1a828f43f557fec673e182a5b3db6a8e4380fc0b6595440dc27f size: 1990
[root@localhost ~]#
如果 命名空间 打开 允许创建仓库 则 /nvidia 可修改