<p>I want to have a container that can access and run kubectl command on my host machine. Here is what  I have:</p>
<ul>
<li>I have installed Kubernetes and Minikube on my host machine.</li>
<li>I used this docker container: <code>helm-kubectl</code> <a href="https://github.com/dtzar/helm-kubectl" rel="nofollow noreferrer">link</a></li>
</ul>
<p>This is the command I run my docker:</p>
<pre><code>docker run -it -v ~/.kube:/root/.kube -v ~/.minikube:/Users/xxxx/.minikube dtzar/helm-kubectl
</code></pre>
<p>Inside the container, when I checked the cluster, I can see the context has loaded my minikube, However, I can't run another kubectl command due to the reason &quot;<strong>The connection to the server 127.0.0.1:32768 was refused - did you specify the right host or port?</strong>&quot;.</p>
<pre><code>bash-5.0# kubectl config get-contexts
CURRENT   NAME                                                           CLUSTER                                                        AUTHINFO                                                       NAMESPACE
          docker-desktop                                                 docker-desktop                                                 docker-desktop
          docker-for-desktop                                             docker-desktop                                                 docker-desktop
*         minikube                                                       minikube                                                       minikube
bash-5.0# kubectl get all
The connection to the server 127.0.0.1:32768 was refused - did you specify the right host or port?
</code></pre>
<p>I have checked my Kubenetes config at <code>~/.kube</code> and the port is 32768.</p>
<pre><code>- cluster:
    certificate-authority: /Users/xxx/.minikube/ca.crt
    server: https://127.0.0.1:32768
  name: minikube
</code></pre>
<p>I have tried port -p 32768 or --expose 32768 but no luck. So anyone can help this?</p>

Tianbing Leng
<p>Thanks zerkms! It works with <code>--network host</code></p>
