Sign inSign up

rjchicago/docker-duper

By rjchicago

Updated about 6 years ago

Duplicate Docker images from one registry to another.

Image
1

1.1K

rjchicago/docker-duper repository overview

docker-duper

Welcome to Docker-Duper!

Docker-Duper is a self-contained image to facilitate duplicating Docker images from one registry to another.

Supported Variables

RequiredVariableDescription
SOURCE_REGISTRYSource Registry. If not supplied, defaults to Docker Hub.
*SOURCE_IMAGESource Image. i.e. alpine or rjchicago/docker-duper
DESTINATION_REGISTRYDestination Registry. i.e. localhost:5000. If not supplied, defaults to Docker Hub.
DESTINATION_IMAGEDestination Image. If not supplied, defaults to $SOURCE_IMAGE
DESTINATION_USERDestination Registry User.
DESTINATION_PASSWORDDestination Registry Password.
TAGTag to copy. If not supplied, defaults to latest.

Example

The following will copy alpine:edge from Alpine's official Docker Hub repo to localhost:5000:

docker run --rm \
  -v /var/run/docker.sock:/var/run/docker.sock \
  -e IMAGE="alpine" \
  -e TAG=edge \
  -e DESTINATION_REGISTRY="localhost:5000" \
  rjchicago/docker-duper

NOTE: update localhost:5000 with your registry

The following will copy alpine:edge from Alpine's official Docker Hub repo to my personal Docker Hub repo:

USER=rjchicago
IMAGE=alpine
TAG=3.12
docker run --rm -it \
  -v /var/run/docker.sock:/var/run/docker.sock \
  -e SOURCE_IMAGE="$IMAGE" \
  -e DESTINATION_IMAGE="$USER/$IMAGE" \
  -e DESTINATION_USER="$USER" \
  -e TAG="$TAG" \
  rjchicago/docker-duper sh

The following will copy alpine:edge from Alpine's official Docker Hub repo to a private DTR repo:

DTR=dtr.cnvr.net
IMAGE=alpine
TAG=3.12
docker run --rm -it \
  -v /var/run/docker.sock:/var/run/docker.sock \
  -e SOURCE_IMAGE="$IMAGE" \
  -e DESTINATION_REGISTRY="$DTR" \
  -e DESTINATION_IMAGE="$(whoami)/$IMAGE" \
  -e DESTINATION_USER="$(whoami)" \
  -e TAG="$TAG" \
  rjchicago/docker-duper sh

docker-duper demo

Note on Insecure Registries

In order to run the demo, you will need to update your Docker insecure registries: https://docs.docker.com/registry/insecure/

For this demo, add localhost:5000

Demo Up

To run the full demo, clone this repo and run the following script:

sh demo\demo-up.sh

The demo will spin up a registry and copy in a couple of images.

Lastly, the demo should pop open a Web browser to http://localhost:8080

Demo Down

To complete and end the demo, run the following script:

sh demo\demo-down.sh

single purpose containers

Docker Run

You can run single purpose containers to copy images as needed.

An official image of docker-duper is available on Docker Hub:

For this example, we'll run the local registry (see note on insecure registries):

docker-compose -f  docker-registry.yml up -d

Next, we'll run a single purpose container to copy docker-duper to our registry:

docker run --rm \
  -v /var/run/docker.sock:/var/run/docker.sock \
  -e IMAGE="rjchicago/docker-duper" \
  -e DESTINATION_REGISTRY="localhost:5000" \
  rjchicago/docker-duper

Preview your registry at http://localhost:8080

Now let's copy over the alpine:latest and alpine:edge images:

docker run --rm \
  -v /var/run/docker.sock:/var/run/docker.sock \
  -e IMAGE="alpine" \
  -e DESTINATION_REGISTRY="localhost:5000" \
  rjchicago/docker-duper
docker run --rm \
  -v /var/run/docker.sock:/var/run/docker.sock \
  -e IMAGE="alpine" \
  -e TAG=edge \
  -e DESTINATION_REGISTRY="localhost:5000" \
  rjchicago/docker-duper

When you're done, don't forget to compose down the demo registry:

docker-compose -f  docker-registry.yml down

Tag summary

Content type

Image

Digest

Size

63.5 MB

Last updated

about 6 years ago

docker pull rjchicago/docker-duper