Hey! are you someone who is concerned about your privacy whenever you have to push or pull images to the cloud registry? Then you can try out storing your docker images on your local machine. There are several other reasons to try this.
For example, better push/pull speed. Major point only you or a select few will have access to this registry which you have allowed to work on some projects. Students who can't afford to pay for a private repository can now work without worrying about any of this and so on.
Intro: A Docker registry is a storage and distribution system for named Docker images.
Steps to install this:
There are two ways; first with 'docker CLI' and second 'docker compose' yaml file .
First method write this "docker run -d -p 5000:5000 -- restart=always
-v give_pathnameYouWant:/var/lib/registry --name=give_any_name registry:2"
Second method:
version: '3' services: myhub: image: registry:2 container_name: myhub volumes: - ./registry_images:/var/lib/registry ports: - 5000:5000 restart: always
Now , we have to create "daemon.json" file if it is not present at (/etc/docker/daemon.json
on linux) and type this "insecure-registries": ["localhost:5000"] in it. This helps us to avoid ssl cert issues when we push and pull our img from our local registry.
In order to push our pulled or build imgs in our docker to local repository. Follow these steps:
docker tag name_of_img ip_address:port/user/img_name:version
Example, docker tag nginx localhost:5000/Luffy/nginx:v1
docker push localhost:5000/goku/nginx:v1
To check pushed img in terminal, 'curl -X GET localhost:5000/v2/_catalog'
Output: