Sometimes it may be necessary to extract the images from a DTR volume backup. In the absence of a functioning DTR cluster, it's possible to extract these images using the open-source registry
image.
First, identify the registry volume that needs to be extracted:
root@dtr-node1:~# docker volume ls --filter=name=dtr
DRIVER VOLUME NAME
local dtr-ca-a2382528a00b
local dtr-postgres-a2382528a00b
local dtr-registry-a2382528a00b
local dtr-rethink-a2382528a00b
Next, navigate to the /var/lib/docker/volumes
directory and copy the contents of the volume to a known location for easy access.
root@dtr-node1:~# cd /var/lib/docker/volumes/
root@dtr-node1:/var/lib/docker/volumes# cp -r dtr-registry-a2382528a00b/ /root/.
Next, create a docker volume to hold our image data. In this example, I created a volume called registry
:
[root@ucp vagrant]# docker volume create registry
Next, copy the image data from the DTR volume into the volume we just created:
[root@ucp volumes]# cp -r /root/dtr-registry-a2382528a00b/_data/ registry/
Now a quick check to ensure that our images are in place:
[root@ucp volumes]# cd registry/
[root@ucp volumes]# tree -L 6 registry
registry
└── _data
└── docker
└── registry
└── v2
├── blobs
│ └── sha256
└── repositories
└── mike
Next, start up a container using the registry:2
image provided by Docker, and mount the named volume we created in the container at /var/lib/registry
:
[root@ucp volumes]# docker run -v registry:/var/lib/registry -d -p 5000:5000 --name registry registry:2
Now let's attempt to pull an image from the registry:
[root@ucp volumes]# docker pull localhost:5000/mike/minecraft
Using default tag: latest
latest: Pulling from mike/minecraft
Digest: sha256:f3c567d7a45bd7ef4ef442ec18842f05c056943662d70c3100fa032253fd3c84
Status: Image is up to date for localhost:5000/mike/minecraft:latest