DEV Community

Cover image for How to setup a local Docker registry with Kubernetes on Windows (includes 1 hidden step that official docs doesn't)?
Rohan Sawant
Rohan Sawant

Posted on

How to setup a local Docker registry with Kubernetes on Windows (includes 1 hidden step that official docs doesn't)?

This post covers how to -

  1. Setup a local Docker registry with Kubernetes on Windows
  2. How to push/pull images to/from the registry

Prerequisites

  1. You have Kubernetes installed
  2. You have Docker installed

Architecture

Alt Text

1A - Steps - Setting up the registry

  1. Start the cluster and allow insecure registries minikube start --insecure-registry "10.0.0.0/24"
  2. Tell minikube to start a registry inside a pod in the Kubernetes cluster minikube addons enable registry
  3. Get the name of the registry pod, in my case it is, (the official docs didn't explain this) registry-s4h7n kubectl get pods --namespace kube-system
  4. Forward all traffic to the registry, run the two commands in separate terminals kubectl port-forward --namespace kube-system registry-s4h7n 5000:5000
  5. Continued - docker run --rm -it --network=host alpine ash -c "apk add socat && socat TCP-LISTEN:5000,reuseaddr,fork TCP:host.docker.internal:5000"
  6. Done. Now, visit. http://localhost:5000/v2/_catalog

1B - Steps - Testing the Setup

  1. git clone https://github.com/CT83/ping-google.git
  2. docker build -t ping-google .
  3. Make sure it works docker run ping-google
  4. Tag it and prepare for push to our newly created registry docker tag ping-google localhost:5000/ping-google
  5. Push it docker push localhost:5000/ping-google

  6. Pull it back down on Kubernetes kubectl create deployment ping-google --image=localhost:5000/ping-google

  7. Ensure it's running kubectl get pods



NAME                           READY   STATUS    RESTARTS   AGE
ping-google-7666ff8964-w5h44   1/1     Running   0          17s


Enter fullscreen mode Exit fullscreen mode

kubectl logs ping-google-7666ff8964-w5h44



PING ns1.google.com (216.239.34.10) 56(84) bytes of data.
64 bytes from ns2.google.com (216.239.34.10): icmp_seq=1 ttl=97 time=73.0 ms

Enter fullscreen mode Exit fullscreen mode




Conclusion

That's basically it, this should greatly simplify your development workflow.

Top comments (0)