之前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成功
1
2
3
4
|
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來查看:
1
2
3
4
5
6
7
8
9
10
|
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其中的倉庫文件是否存在:
1
2
|
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鏡像。
1
2
3
4
5
6
7
8
|
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:
1
2
3
4
5
|
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下來。
感謝閱讀,希望能幫助到大家,謝謝大家對本站的支持!