Skip to content

Instantly share code, notes, and snippets.

Created November 9, 2017 01:06
Show Gist options
  • Save anonymous/766171275f82362737a4b5d3c11b9f6e to your computer and use it in GitHub Desktop.
Save anonymous/766171275f82362737a4b5d3c11b9f6e to your computer and use it in GitHub Desktop.
extract images from DTR with oss registry

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment