Copy a Docker image from one registry to another

Copying docker images is useful to prevent losing access to an image if the remote registry goes down or to move images between environments (For example: from testing to production)

The process consists in pulling an image from an origin repository, change the tag, and push the image to a remote repository.

Example:

# Login to docker registries
docker login registry-testing.thingsandcode.com -u=Branyac -p=FakePassw0rd
docker login registry-production.thingsandcode.com -u=Branyac -p=FakePassw0rd

# Pull source image
docker pull registry-testing.thingsandcode.com/thingsandcode-web:20220830-test

# Change tag to match the desired tag for the remote registry
docker tag registry-testing.thingsandcode.com/thingsandcode-web:20220830-test registry-production.thingsandcode.com/thingsandcode-web:20220830-pro

# Upload image to the remote registry
docker push registry-production.thingsandcode.com/thingsandcode-web:20220830-pro