Docker registry and Configure private registry on centos 7

Docker Registry: A repository of images. Registries are public or private that contain images for download. Some registries allow users to upload images to make them available to others

Dockerfile: A configuration file with build instructions for Docker image.Dockerfile automate the steps for image customization.

As we discussed two types of registry are available:

Public Docker Registry: Users just want to explore or want a in-build solution. They can use hosted docker registries. Docker hub is the example of public registry where user can host the registry.

Private Docker Registry: Lot of organization have security concern for public docker registry. They want to manage and store the customize image, only want to share in  the organization can go for private docker registry.

Note: In this post, I will be configuring the private docker registry.

cat /etc/centos-release
CentOS Linux release 7.2.1511 (Core)

Installing docker-registry

yum install docker-registry

//Docker Registry Configuration file  :rpm -ql  under etc directory             [root@localhost amit]# rpm -ql docker-registry-0.9.1-7.el7.x86_64
/etc/docker-registry.yml
/etc/sysconfig/docker-registry

//Docker Registry default image store location

Cat /etc/docker-registry.yml

local: &local
<<: *common
storage: local
storage_path: _env:STORAGE_PATH:/var/lib/docker-registry

//Enable and start the docker registry and default port is 5000:                 systemctl enable docker-registry                                                                      systemctl start docker-registry

systemctl status docker-registry
docker-registry.service - Registry server for Docker
 Loaded: loaded (/usr/lib/systemd/system/docker-registry.service; enabled; vendor preset: disabled)
 Active: active (running) since Tue 2017-01-24 13:21:37 IST; 55s ago
 Main PID: 24323 (gunicorn)
 Memory: 162.8M
 CGroup: /system.slice/docker-registry.service

netstat -tupln|grep 5000
tcp 0 0 0.0.0.0:5000 0.0.0.0:* LISTEN 24323/python

Docker registry is running on one of the host node, It need to be accessed by other nodes for uploading/downloading the images.

On the client node which need access the private registry need to modify /etc/sysconfig/docker

DOCKER_OPTS=”–insecure-registry localhost:5000″

link: https://docs.docker.com/registry/insecure/

//tag and push the image to docker registry

docker tag  <image id>  <ip of docker registry>:5000/<name>:<tag>

docker push    <ip of docker registry>:5000/<name>:<tag>

docker tag ff6f0851ef57 localhost:5000/jenkinslocal:latest
docker push localhost:5000/jenkinslocal:latest 
The push refers to a repository [localhost:5000/jenkinslocal]
7fef8c44bf7f: Image successfully pushed 
971a0fc79a1a: Image successfully pushed 
5b8b7745040c: Image successfully pushed 
7d114ad7e1fe: Image successfully pushed 
5b848d38b406: Image successfully pushed 
4e87708e08e8: Image successfully pushed 
d458e9b86b04: Image successfully pushed 
ca787184f0ab: Image successfully pushed 
4238f6371816: Image successfully pushed 
a2eea3e16ec7: Image successfully pushed 
1f764d32a220: Image successfully pushed 
1af14ac896ef: Image successfully pushed 
a7afeb77f416: Image successfully pushed 
cef349a9d76f: Image successfully pushed 
1d16eb83eef5: Image successfully pushed 
dfe1af64a72d: Image successfully pushed 
9f17712cba0b: Image successfully pushed 
223c0d04a137: Image successfully pushed 
fe4c16cbf7a4: Image successfully pushed 
Pushing tag for rev [ff6f0851ef57] on {http://localhost:5000/v1/repositories/jenkinslocal/tags/latest}