title: How to connect to k8s cluster of docker desktop on another machine?
body: <p>I have a macbook (<code>192.168.1.101</code>) and a macmini(<code>192.168.1.104</code>) over same wifi.</p>
  
  <p>I launched a k8s cluster through docker-desktop on macmini and would like to access it through <code>kubectl</code> on macbook.</p>
  
  <p>Here is how my <code>~/.kube/config</code> on macmini looks like:</p>
  
  <pre><code>apiVersion: v1
  clusters:
  - cluster:
      certificate-authority-data: ******
      server: https://kubernetes.docker.internal:6443
    name: docker-desktop
  contexts:
  - context:
      cluster: docker-desktop
      user: docker-desktop
    name: docker-desktop
  - context:
      cluster: docker-desktop
      user: docker-desktop
    name: docker-for-desktop
  current-context: docker-desktop
  kind: Config
  preferences: {}
  users:
  - name: docker-desktop
    user:
      client-certificate-data: ******
      client-key-data: ******
  </code></pre>
  
  <p>How can I write <code>~/.kube/config</code> on macbook? Currently I followed official <a href="https://kubernetes.io/docs/tasks/access-application-cluster/configure-access-multiple-clusters/" rel="noreferrer">doc</a> and got following errors.</p>
  
  <pre><code>$ kubectl config view
  apiVersion: v1
  clusters:
  - cluster:
      certificate-authority-data: DATA+OMITTED
      server: http://192.168.1.104:6443
    name: macmini-cluster
  contexts:
  - context:
      cluster: macmini-cluster
      user: macmini-user
    name: macmini-context
  current-context: macmini-context
  kind: Config
  preferences: {}
  users:
  - name: macmini-user
    user:
      client-certificate-data: REDACTED
      client-key-data: REDACTED
  $ kubectl get pods
  The connection to the server 192.168.1.104 was refused - did you specify the right host or port?
  </code></pre>
  
  <p><strong>Update</strong>:</p>
  
  <p>I added port <code>6443</code> to <code>server</code> of <code>cluster</code> and tried to <code>telnet</code> macmini's port <code>6443</code>, but got:</p>
  
  <pre><code>$ telnet 192.168.1.104 6443
  Trying 192.168.1.104...
  telnet: connect to address 192.168.1.104: Connection refused
  telnet: Unable to connect to remote host
  </code></pre>
  
  <p>When I checked on macmini:</p>
  
  <pre><code>$ netstat -na|grep 6443
  tcp4       0      0  127.0.0.1.6443         *.*                    LISTEN
  </code></pre>
  
  <p>There seems to be an unresolved related <a href="https://github.com/docker/for-mac/issues/3730" rel="noreferrer">issue</a>.</p>