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 gcr.io/k8s-minikube/kicbase:v0.0.11 "/usr/local/bin/entr…" 3 weeks ago Up 2 hours 127.0.0.1:32795->22/tcp, 127.0.0.1:32794->2376/tcp, 127.0.0.1:32793->5000/tcp, 127.0.0.1:32792->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