Docker private warehouse recovery example details
- 2020-05-24 06:29:47
- OfStack
Docker private warehouse restored
Before, the host of registry private warehouse made before was down due to power failure and other influences on openstack platform. Fortunately, the data was mounted in nfs, and now it is trying to restart and restore.
The virtual machine installs the nfs service
apt-get install -y nfs-common
Edit/etc/fstab
Write to the remote mount address
10.50.8.12:/export/DockerRepo /var/lib/docker/registry nfs defaults 0 0
Then mount:
mount -a -v
The output below indicates that mount was successful
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
You can use df to see:
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
Create a new registry
The command is
# docker run -d -p 5000:5000 -v /var/lib/docker/registry:/tmp/registry registry
Where -p is port mapping with the host, -v means mounting volume of the host into the container, and mounting our nfs into the container to be used as storage of Docker private warehouse.
See if it was created successfully
Use the curl command to determine if the search warehouse file exists:
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"}]}
Test private repository
Pull ubuntu: 14.04 image from private warehouse.
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
You can then view the existing images via docker 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
From the private warehouse, it only takes more than 10 seconds to transfer ubuntu's 200-plus m images to pull.
Thank you for reading, I hope to help you, thank you for your support of this site!