From 9631d35a14cac5717f99e9173703e8474261a122 Mon Sep 17 00:00:00 2001 From: David Taylor Date: Fri, 7 Feb 2020 12:57:57 -0600 Subject: [PATCH] Add instructions for Windows host Instructions for MacOS do not work as-is for Windows. Need to add an additional step. --- .../en/docs/Tasks/Registry/insecure.md | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/site/content/en/docs/Tasks/Registry/insecure.md b/site/content/en/docs/Tasks/Registry/insecure.md index 0ccf96789938..e3f1116014ca 100644 --- a/site/content/en/docs/Tasks/Registry/insecure.md +++ b/site/content/en/docs/Tasks/Registry/insecure.md @@ -42,3 +42,39 @@ docker push localhost:5000/myimage ``` After the image is pushed, refer to it by `localhost:5000/{name}` in kubectl specs. + +### Docker on Windows + +Quick guide for configuring minikube and docker on Windows, enabling docker to push images to minikube's registry. + +The first step is to enable the registry addon: + +``` +minikube addons enable registry +``` + +When enabled, the registry addon exposes its port 5000 on the minikube's virtual machine. + +In order to make docker accept pushing images to this registry, we have to redirect port 5000 on the docker virtual machine over to port 5000 on the minikube machine. Unfortunately, the docker vm cannot directly see the IP address of the minikube vm. To fix this, you will have to add one more level of redirection. + +Use kubectl port-forward to map your local workstation to the minikube vm +``` +kubectl port-forward --namespace kube-system 5000:5000 +``` + +On your local machine you should now be able to reach the minikube registry by using `curl http://localhost:5000/v2/_catalog` + +From this point we can (ab)use docker's network configuration to instantiate a container on the docker's host, and run socat there to redirect traffic going to the docker vm's port 5000 to port 5000 on your host workstation. + +``` +docker run --rm -it --network=host alpine ash -c "apk add socat && socat TCP-LISTEN:5000,reuseaddr,fork TCP:host.docker.internal:5000" +``` + +Once socat is running it's possible to push images to the minikube registry from your local workstation: + +``` +docker tag my/image localhost:5000/myimage +docker push localhost:5000/myimage +``` + +After the image is pushed, refer to it by `localhost:5000/{name}` in kubectl specs.