Minikube Docker Registry

I run minikube with hyperkit. Enabling a docker registry has minikube dynamically allocating a port on every start. I would prefer to keep this port static so I can reference it in my scripts, but have not found a way to do so.

But I have found you can easily do port forwarding with socat. Find the port that minikube is running with docker ps -a:

ec33087e8aaf     "/usr/local/bin/entr…"   3 weeks ago         Up 2 hours>22/tcp,>2376/tcp,>5000/tcp,>8443/tcp   minikube

We see that 32793 is the exposed port for the registry (5000). Now run another container to accept connections on port 5000 and forward them to minikube port 32793:

docker run --rm -it -d --network=host alpine ash -c "apk add socat && socat TCP-LISTEN:5000,reuseaddr,fork TCP:$(minikube ip):32793"

Now you can push an image outside of minikube – docker push localhost:5000/test:1234 – then ssh to minikube (minikube ssh) and pull the same image – docker pull localhost:5000/test:1234

Leave a Reply

Your email address will not be published. Required fields are marked *