Docker 之十一实战 Push 镜像到阿里云镜像仓库

设置 Registry 登录密码

docker-push-aliyun-0

创建命名空间

docker-push-aliyun-1

创建镜像仓库(本地)

docker-push-aliyun-2

将本地镜像推送到镜像仓库

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# 在下面的操作中,链接registry.cn-shenzhen.aliyuncs.com可以从阿里云的镜像仓库管理页面获取

# 登录阿里云Docker Registry,成功后帐号信息默认存放在 ~/.docker/config.json
# docker login --username=[用户名] registry.cn-shenzhen.aliyuncs.com

# tag命令官方语法: docker tag SOURCE_IMAGE[:TAG] TARGET_IMAGE[:TAG]
# tag命令官方解释: Create a tag TARGET_IMAGE that refers to SOURCE_IMAGE

# 创建目标镜像,其中peter-docker-study是命名空间,centos-test是仓库名称
# docker tag [镜像ID] registry.cn-shenzhen.aliyuncs.com/peter-docker-study/centos-test:[镜像版本号]

# 查看本地镜像
# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
registry.cn-shenzhen.aliyuncs.com/peter-docker-study/centos-test [镜像版本号] [镜像ID] 1 hours ago 385MB

# 将本地镜像Push到阿里云镜像仓库
# docker push registry.cn-shenzhen.aliyuncs.com/peter-docker-study/centos-test:[镜像版本号]

从镜像仓库拉取镜像到本地

1
2
3
4
5
6
7
8
9
10
# 拉取镜像到本地,其中peter-docker-study是命名空间,centos-test是仓库名称
# docker pull registry.cn-shenzhen.aliyuncs.com/peter-docker-study/centos-test:[镜像版本号]

# 查看本地镜像
# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
registry.cn-shenzhen.aliyuncs.com/peter-docker-study/centos-test [镜像版本号] [镜像ID] 1 hours ago 385MB

# 以交互式运行Pull下来的Docker镜像
# docker run -it --name=“peter-centos” registry.cn-shenzhen.aliyuncs.com/peter-docker-study/centos-test:[镜像版本号]