This article demonstrates publishing an image using the Docker Registry in a development or test environment and configuring K8s to use that image repository.
- Pull Image
docker pull registry
- Generate a password
sudo apt-get install apache2-utils
Generate the password and store it in /opt/docker/register/auth foloder.
sudo mkdir /opt/docker/registry/auth -p
htpasswd -Bbn admin admin123 > /opt/docker/registry/auth/htpasswd
- Startup Registry
docker run -d -p 5000:5000 \
docker login 192.168.0.135:5000
Note Replace 192.168.0.135 with the intranet address of your server
Error response from daemon: Get https://192.168.0.135:5000/v2/: http: server gave HTTP response to HTTPS client
This is because we did not configure SSL for this Regsitry (intranet and test environment, which can be used as such)
Add the following line into daemon.json file.
Also note: Replace 192.168.0.135 with the intranet address of your server
Restart docker, then execute:
sudo systemctl restart docker
- Create a secret, execute the following command in the Master of Kubernetes cluster.
kubectl create secret docker-registry my-registry-secret --docker-server=192.168.0.135:5000 --docker-username=admin --docker-password=admin123
After a successful build, you can view it with the following command
kubectl get secret
Because SSL is not configured for registry, you need to modify /etc/docker/daemon.json for each Node in the cluster
Add the following