Create Private Docker Registry for MiniKube

  1. Edit /etc/hosts and map host
    <$minikube ip> host.minikube.internal
  2. Add insecere-registries=”host.minikube.internal:5000″ in daemon.json
  3. Restart docker
  4. Start minikube insecure mode
    minikube start –insecure-registry=host.minikube.internal:5000 –insecure-registry=192.168.1.37
  5. Setup selfcert http://www.selfsignedcertificate.com/ and save host.minikube.internal.cert and host.minikube.internal.key
  6. Copy selfcert to minikube node
    scp -i $(minikube ssh-key) -pr selfcert/ docker@$(minikube ip):
    6.1 minikube ssh
    6.2 sudo cp -rvf selfcert /etc/docker/certs.d/host.minikube.internal:5000
    6.3 cd /etc/docker/certs.d/host.minikube.internal:5000 ; sudo openssl s_client -showcerts -connect host.minikube.internal:5000 < /dev/null | sed -ne ‘/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p’ > ca.crt
    6.4 exit from minikube
  7. Create docker user and password
    docker container run -i –rm –entrypoint htpasswd registry:2.6.2
    -Bbn admin password >> ./selfcert/htpasswd
  8. Copy cert to host
    cp cert to /etc/docker/certs.d
    sudo cp -rvf selfcert /etc/docker/certs.d/host.minikube.internal:5000
  9. Create ca.crt file
    openssl s_client -showcerts -connect : host.minikube.internal:5000 < /dev/null | sed -ne ‘/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p’ > ca.crt
  10. Run registry

    docker container run -itd -p 5000:5000
    –name registry
    –restart=always
    -v /home/warawich/Documents/registry/selfcert:/certs
    -v /home/warawich/Documents/registry/selfcert:/auth
    -e “REGISTRY_AUTH=htpasswd”
    -e “REGISTRY_AUTH_HTPASSWD_REALM=Registry Realm”
    -e REGISTRY_AUTH_HTPASSWD_PATH=/auth/htpasswd
    -e REGISTRY_STORAGE_DELETE_ENABLED=true
    -e REGISTRY_HTTP_TLS_CERTIFICATE=/certs/host.minikube.internal.cert
    -e REGISTRY_HTTP_TLS_KEY=/certs/host.minikube.internal.key
    registry:2.6.2
  11. Testing login from Host
    docker login host.minikube.internal:5000
  12. Testing login from minikube
    minikube ssh – docker login host.minikube.internal:5000