How to set up a Docker Registry v2 using redis for caching
Run redis container
$ docker run --name cache-redis -d -p 6379:6379 redis
Get the IP of the host
Use the IP of the docker host. Example using docker-machine:
MY_IP=$(docker-machine ip $(docker-machine active))
Run Docker Registry v2 container
For official documentation about registry configuration -> go here.
Example:
- specify redis as the caching method: define env var
REGISTRY_STORAGE_CACHE_BLOBDESCRIPTOR=redis
- define redis minimal conf: define env var
REGISTRY_REDIS_ADDR=$MY_IP:6379
Look at the setup redis-registry running
$ docker logs -f registry
Startup
In the startup logs you can see:
level=info msg="using redis blob descriptor cache"
=> redis enabled as caching storage
Push an image to the registry
From another terminal, push an image to the docker registry:
$ docker tag httpd:latest localhost:5000/httpd
$ docker push localhost:5000/httpd
In the logs there is:
level=info msg="redis: connect 192.168.99.100:6379"
=> connection succesful with redis server
Inspect redis DB: run the redis-cli & query the k/v store
–> SUCCESS: the Docker registry used redis as a caching storage