Local Docker Container Registry

Local Docker Container Registry

When working locally with kubernetes, having a local registry is very convenient because it keeps your docker hub ( or any remote registry for that matter), clean, uses less bandwidth, and allows the software/devops engineer to experiment with the images and cluster.

Setup

Looking through the docker hub we find a repo called registry.

Easily enough we run:

docker run -d -p 5000:5000 --restart always --name registry registry:2

Push / Pull

Now we can push and pull from this local repositoty

docker image tag my-image localhost:5000/my-image
docker push localhost:5000/my-image
docker pull ...

View Images

To display images we can simply run:

$ curl -X GET http://localhost:5000/v2/_catalog

Start Registry Again

After reboot (or just docker boot) we can run our registry again with:

docker start registry

Another solution would be to use the --restart=always parameter:

docker run -d -p 5000:5000 --name registry --restart=always registry:latest

Remove Registry

docker container stop registry && docker container rm -v registry

For more detailed information, maybe to even use your own registry in production, visit