Use minio as docker registry storage driver

Among all the various ways of saving files, Amazon s3 service has defined a standard, a lot of services and software supports natively using it as “Object block storage” (that is just a fancy alternative for “saves files and stuff”) and nowadays there are a lot of s3 drop-in replacements.

My favourite one in minio, written in go and ridiculously easy to set up, for the installation you should look at the official documentation.

Today i will show you a little thing i have put up with minio, using it as a remote storage for my private docker registry

Variables

Keep in mind you will need a working minio installation with an dedicated bucket, and the following variables:

NAME                   EXAMPLE
{MINIO_ACCESS_KEY} => PWMJHQ01EXRWYRVM3UJB
{MINIO_SECRET_KEY} => N2nEexm6bSEITcvrA97Mu/uR/yvWpy1bXoGGetYE
{REGION} => us-east-1
{REGION_ENDPOINT} => https://minio.example.com:9000/
{BUCKET_NAME} => docker-registry

Configuration

We have to write two configuration files, one for the registry configuration (config.yml) and one to build a docker image that uses it (Dockerfile)

config.yml

version: 0.1
log:
fields:
service: registry
http:
addr: :5000
storage:
cache:
layerinfo: inmemory
s3:
accesskey: {MINIO_ACCESS_KEY}
secretkey: {MINIO_SECRET_KEY}
region: {REGION}
regionendpoint: {REGION_ENDPOINT}
bucket: {BUCKET_NAME}
encrypt: false
secure: true
v4auth: true
chunksize: 5242880
rootdirectory: /

Dockerfile

FROM registry:2
COPY config.yml /etc/docker/registry/config.yml

Note: Be sure to run the lastest version of minio, versions before “RELEASE.2017–02–16T01–47–30Z” are incompatible with versions of docker registy greater than 2.5.1

Build and run

Now assuming that the Dockerfile and the config.yml are in the current working directory you will have to run those commands:

# Build the docker image
docker build . --tag=my-registry-name
# Run the image
docker run -d -p 5000:5000 my-registry-name

And you are done!

You can now push and pull images from the docker registry and have all saved in minio, you can try deleting & recreating the running registry container and see that the pushed images will be still there :)

One clap, two clap, three clap, forty?

By clapping more or less, you can signal to us which stories really stand out.