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 -vmount.nfs: timeout set for Thu Mar 26 13:12:44 2015mount.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# dfFilesystem 1K-blocks Used Available Use% Mounted on/dev/vda1 165106028 1780156 156584392 2% /none 4 0 4 0% /sys/fs/cgroupudev 8211996 12 8211984 1% /devtmpfs 1643392 348 1643044 1% /runnone 5120 0 5120 0% /run/locknone 8216952 0 8216952 0% /run/shmnone 102400 0 102400 0% /run/user10.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.04Pulling repository 127.0.0.1:5000/ubuntu2103b00b3fdf: 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 imagesREPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZEregistry latest e33e81d7024c 5 days ago 413.7 MB127.0.0.1:5000/ubuntu latest 2103b00b3fdf 2 weeks ago 192.7 MB127.0.0.1:5000/ubuntu 14.04 2103b00b3fdf 2 weeks ago 192.7 MB
從私有倉庫只需要10多秒即可將ubuntu的200多m的鏡像給pull下來。
感謝閱讀,希望能幫助到大家,謝謝大家對本站的支持!
新聞熱點
疑難解答
圖片精選