This is a very simple Bash shell script that converts local Docker container images into the registry distribution format and structure. The tool then uploads that structure via rclone
to your R2 bucket of choice. The end result is having a Docker registry compatible URL on R2.
Example URL: docker pull pub-6975b173047b49bf97e9146ff7808721.r2.dev/myapp:v1.0.0
Example URL with custom domain: docker pull images.sheldon.is/myapp:v1.0.0
- skopeo - Toolkit for container images
- rclone - Upload container image structure to R2
- jq - CLI utility for handling JSON data
Most notably, read-only access to images.
Jérome (who inspired this all-in-one script) goes over the other limitations of using a static-file-like-host such as R2 here.
First, build your Docker image as you normally would.
cd myapp
docker build -t myapp .
docker tag myapp:latest myapp:v1.0.0
Next, install r2-registry:
git clone https://github.com/fieu/r2-registry
cd r2-registry
./generate.sh [image] [tag]
Now, setup your environment variables that are used by the script:
CLOUDFLARE_ACCOUNT_ID
- Cloudflare account ID (found here)R2_BUCKET
- Name of R2 bucket to store image contentsR2_ACCESS_KEY_ID
- R2 Access Key (info)R2_SECRET_ACCESS_KEY
- R2 Secret Access Key (info)R2_DOMAIN
- R2 custom domain (optional) (info)
export CLOUDFLARE_ACCOUNT_ID=123456789
export R2_BUCKET=docker-images
export R2_ACCESS_KEY_ID=123
export R2_SECRET_ACCESS_KEY=123
export R2_DOMAIN=images.sheldon.is
./generate.sh myapp v1.0.0
Try and pull my image from my R2 bucket:
docker pull images.sheldon.is/myapp:v1.0.0
$ ./generate.sh
Usage: ./generate.sh <image> <tag>
image (string) The name of the image to build
tag (string) The tag of the image to build
Contributions are welcome and will be fully credited.
I accept contributions within project scope via Pull Requests on GitHub.
jpetazzo/registrish - Initial concept and code snippets
r2-registry is open-sourced software licensed under the MIT License.