可以看到 registry 的镜像和一个本地 ubuntu:12.04 的镜像
3.重新标记一个本地镜像为私有仓库的版本,这里将本地的 ubuntu 12.04 标记为 localhost:5000/ubuntu:1204。
1 | docker tag ubuntu:12.04 localhost:5000 /ubuntu :1204 |
再次查看镜像可以看到多了一个标记为 localhost:5000/ubuntu:1204 的镜像
4.将本地镜像推送到本地仓库中
1 | docker push localhost:5000 /ubuntu :1204 |
5.查看本地仓库中的镜像列表
1 | curl http: //localhost :5000 /v2/ubuntu/tags/list |
结果如下:
1 | { "name" : "ubuntu" , "tags" :[ "1204" ]} |
6.从本地仓库拉取一个镜像,在这之前先执行如下命令移除本地未使用的镜像,保证从本地仓库拉取的镜像不是从缓存中获取。
1 | docker rmi -f $(docker images -q -a ) |
之后再查看镜像,只剩下 registry 这个镜像
拉取本地仓库中的镜像
12345678 | docker pull localhost:5000 /ubuntu :1204 Unable to find image 'localhost:5000/ubuntu:1204' locally 1204: Pulling from localhost:5000 /ubuntu b796a17a2688: Pull complete 273721eafe54: Pull complete 7dd38dbb5eda: Pull complete 32190de3770a: Already exists |
之后查看镜像如下:
最后正常启动
1 | docker run --name mytestubuntu localhost:5000 /ubuntu :1204 |