In this demo I am using "CentOS Linux release 7.7.1908 (Core)".
Local registry host name: mylocalregistry.local
Step 1
Add local DNS record for /etc/hosts file
vi /etc/hosts
Step 2
Install and enable docker service in each servers
yum install docker-ce docker-ce-cli containerd.io
systemctl enable docker
systemctl start docker
Step 3
Disable SELinux
setenforce 0
Also change the "/etc/selinux/config" to make it permanent.
Step 4
Edit the daemon.json file, whose default location is /etc/docker/daemon.json on each docker host servers.
{
"insecure-registries" : ["mylocalregistry.local:5000"]
}
Note: Once you done the change restart the docker service.
Step 5
Generate self sigh certificate
mkdir -p /certs
openssl req \
-newkey rsa:4096 -nodes -sha256 -keyout /certs/mylocalregistry.local.key \
-x509 -days 365 -out /certs/mylocalregistry.local.crt
Copy mylocalregistry.local.crt to /etc/pki/ca-trust/source/anchors/
Update trust certificate list.
Step 6
Create local registry
Execute below command
docker run -d --restart=always --name my-docker-registry -v /certs:/certs -e REGISTRY_HTTP_ADDR=0.0.0.0:443 -e REGISTRY_HTTP_TLS_CERTIFICATE=/certs/mylocalregistry.local.crt -e REGISTRY_HTTP_TLS_KEY=/certs/mylocalregistry.local.key -p 443:443 -p 5000:5000 registry:2
To verify the docker repo running



No comments:
Post a Comment