[root@docker-images ~]# docker start 1e8 #开启本地库
1e8
[root@docker-images ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
1e8b1a03013e docker.io/registry "/entrypoint.sh /etc/" 4 hours ago Up 3 seconds 0.0.0.0:5000->5000/tcp goofy_mcnulty
[root@docker-images ~]#
[root@docker-images ~]# docker push 127.0.0.1:5000/ssh #上传打好标签的库
The push refers to a repository [127.0.0.1:5000/ssh]
482d621bda33: Pushed
510f15c27a8b: Pushed
e4f86288aaf7: Pushed
latest: digest: sha256:5ad5aec14bb7aa63fdcea1772db6ab5b5de99b0a023d234e61f5aa8c9435e8ff size: 948
[root@docker-images ~]#
8、查看已经上传好的镜像
[root@docker-images ~]# curl 10.0.0.5:5000/v2/_catalog
{"repositories":["ssh"]}
[root@docker-images ~]#
浏览器中查看已经上传的镜像
:5000/v2/_catalog
9、测试库是否可用,在准备好环境的另一台测试机上面下载上传的镜像
[root@centos7 ~]# vim /etc/sysconfig/docker #加入私有仓库地址
OPTIONS="--selinux-enabled --insecure-registry 10.0.0.5:5000"
[root@centos7 ~]# systemctl restart docker
[root@centos7 ~]# docker pull 10.0.0.5:5000/ssh
可以看到已经可以下载镜像,证明私有仓库创建成功
[root@centos7 ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
10.0.0.5:5000/ssh latest ad6a3ff29626 4 weeks ago 396.7 MB
[root@centos7 ~]#
接下来通过自己的私有库运行一个centos7容器
1、从其他的数据库上save一个centos镜像推送到私有库服务器上
[root@docker-images ~]# ls
anaconda-ks.cfg centos.tar
[root@docker-images ~]# docker load < centos.tar #将镜像导入docker
34e7b85d83e4: Loading layer [==================================================>] 199.9 MB/199.9 MB
Loaded image: docker.io/centos:latest ] 557.1 kB/199.9 MB
[root@docker-images ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
docker.io/registry latest 047218491f8c 10 days ago 33.17 MB
127.0.0.1:5000/ssh latest ad6a3ff29626 4 weeks ago 396.7 MB
docker.io/fedora/ssh latest ad6a3ff29626 4 weeks ago 396.7 MB
docker.io/centos latest 67591570dd29 12 weeks ago 191.8 MB
[root@docker-images ~]#
2、再次打上自己的标签
[root@docker-images ~]# docker tag docker.io/centos:latest 10.0.0.5:5000/lcentos
#为了区别前面的,我将centos做了其他标记
[root@docker-images ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
docker.io/registry latest 047218491f8c 10 days ago 33.17 MB
127.0.0.1:5000/ssh latest ad6a3ff29626 4 weeks ago 396.7 MB
docker.io/fedora/ssh latest ad6a3ff29626 4 weeks ago 396.7 MB
docker.io/centos latest 67591570dd29 12 weeks ago 191.8 MB
10.0.0.5:5000/lcentos latest 67591570dd29 12 weeks ago 191.8 MB
[root@docker-images ~]#
3、上传标记好的镜像到自己的私有库
[root@docker-images ~]# docker push 10.0.0.5:5000/lcentos
4、查看上传好的镜像
[root@docker-images ~]# curl :5000/v2/_catalog
{"repositories":["lcentos","ssh"]}
[root@docker-images ~]#
浏览器查看
5、再次到准备好环境的那台测试机上面pull