Local docker registry as default registry

Problem statement: In multi node docker environment, make private registry as default registry

Environment detail: Oracle virtual box has two centos 7 instance installed. 
- node 1: docker and docker registry setup
    yum install docker*
    enable the docker service and start it:
     systemctl enable docker
     systemctl start docker
    running a registry in container form: 
     docker run -d -p 5000:5000 --restart=always --name registry registry:2
    push any local image to local registry [below is the example to setup image from docker.io to private registry]
     docker pull ubuntu:16.04 /*it will pull from docker.io*/
     docker tag ubuntu:16.04 localhost:5000/my-ubuntu
     docker push localhost:5000/my-ubuntu
    docker image remove ubuntu:16.04
    docker image remove localhost:5000/my-ubuntu
- node 2: only docker installed
    yum install docker*
 Note: we will pull local image from node1

Steps to make private registry default registry and accessible remotely

 Stop docker service : systemclt stop docker
- Check docker info command: docker info /* check for registry and insecure registry)
- Add entry in /etc/sysconfig/docker file on all the node(node1 and node 2 in this case)
   vi /etc/sysconfig/docker
   ADD_REGISTRY='--add-registry 192.168.0.108:5000'
- Add entry in /etc/docker/daemon.json 
 vi /etc/docker/daemon.json 
{
"insecure-registries" : [ "192.168.0.108:5000" ]
}
- start the docker service
  systemctl start docker
check the docker info command
 docker info
Registry: https://192.168.0.108:5000/v1/
Experimental: false
Insecure Registries:
 192.168.0.108:5000
 127.0.0.0/8
from node 2 pull the image
 docker pull my-ubuntu

[root@target-2 /]# docker pull my-ubuntu
Using default tag: latest
Trying to pull repository 192.168.0.108:5000/my-ubuntu ...
latest: Pulling from 192.168.0.108:5000/my-ubuntu
7b378fa0f908: Pull complete
4d77b1b29f2e: Pull complete
7c793be88bae: Pull complete
ecc05c8a19c0: Pull complete

amit
Working as an Architect, Infra designer. If any query related to Infra Design [related to cloud,vmware,openstack], please write: amit@openwriteup.com