Docker 私有仓库恢复 Docker 私有仓库恢复实例详解
人气:0想了解Docker 私有仓库恢复实例详解的相关内容吗,在本文为您仔细讲解Docker 私有仓库恢复的相关知识和一些Code实例,欢迎阅读和指正,我们先划重点:Docker,私有仓库恢复,Docker,私有仓库恢复实现,Docker,私有仓库恢复实例详解,下面大家一起来学习吧。
Docker 私有仓库恢复
之前openstack平台由于停电等影响,导致之前制作的registry 私有仓库的主机挂掉,还好数据挂载在nfs中,然后现在尝试重新启动恢复。
虚机安装nfs服务
apt-get install -y nfs-common
编辑 /etc/fstab
写入远程挂载地址
10.50.8.12:/export/DockerRepo /var/lib/docker/registry nfs defaults 0 0
然后进行挂载:
mount -a -v
输出如下结果,表明mount成功
root@docker-registry:/home/ubuntu# mount -a -v mount.nfs: timeout set for Thu Mar 26 13:12:44 2015 mount.nfs: trying text-based options 'vers=4,addr=10.50.8.12,clientaddr=10.0.0.244' nothing was mounted
可以用df来查看:
root@docker-registry:/home/ubuntu# df Filesystem 1K-blocks Used Available Use% Mounted on /dev/vda1 165106028 1780156 156584392 2% / none 4 0 4 0% /sys/fs/cgroup udev 8211996 12 8211984 1% /dev tmpfs 1643392 348 1643044 1% /run none 5120 0 5120 0% /run/lock none 8216952 0 8216952 0% /run/shm none 102400 0 102400 0% /run/user 10.50.8.12:/export/DockerRepo 515931136 683008 489017344 1% /var/lib/docker/registry
创建新的registry
命令如下
# docker run -d -p 5000:5000 -v /var/lib/docker/registry:/tmp/registry registry
其中 -p是与主机进行端口映射,-v表示将主机的volume挂载到容器中,即将我们的nfs挂载到容器中,作为Docker 私有仓库的存储使用。
查看是否创建成功
用curl命令来search其中的仓库文件是否存在:
root@docker-registry:/var/lib/docker/registry/images# curl http://127.0.0.1:5000/v1/search {"num_results": 8, "query": "", "results": [{"description": null, "name": "shipyard/rethinkdb"}, {"description": null, "name": "shipyard/shipyard"}, {"description": null, "name": "shipyard/shipyard-cli"}, {"description": null, "name": "library/mysql"}, {"description": null, "name": "library/ubuntu"}, {"description": null, "name": "library/registry"}, {"description": null, "name": "library/centos"}, {"description": null, "name": "tutum/influxdb"}]}
测试私有仓库
从私有仓库拉取ubuntu:14.04镜像。
root@docker-registry:/var/lib/docker/registry/images# docker pull 127.0.0.1:5000/ubuntu:14.04 Pulling repository 127.0.0.1:5000/ubuntu 2103b00b3fdf: Download complete 511136ea3c5a: Download complete f0dde87450ec: Download complete 76b658ecb564: Download complete 4faa69f72743: Download complete Status: Downloaded newer image for 127.0.0.1:5000/ubuntu:14.04
然后可以通过docker images来查看存在的images:
root@docker-registry:/var/lib/docker/registry/images# docker images REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE registry latest e33e81d7024c 5 days ago 413.7 MB 127.0.0.1:5000/ubuntu latest 2103b00b3fdf 2 weeks ago 192.7 MB 127.0.0.1:5000/ubuntu 14.04 2103b00b3fdf 2 weeks ago 192.7 MB
从私有仓库只需要10多秒即可将ubuntu的200多m的镜像给pull下来。
感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!
加载全部内容