Connecting to Kubernetes on Docker on OSX?

I’m on an OSX host using docker-machine to manage my docker installation. I’m trying to get a kubernetes cluster set up and I’m having a hard time running kubectl on my host.

Right now I’m running this to launch it:

  • systemctl from inside docker container fails with D-Bus connection error
  • shared folder doesn't contain data
  • How to create docker containers with the same internal IP address?
  • How to specify docker image's DNS?
  • Docker Change Port Binding
  • Boot2Docker for OS X fails to start
  • .  # Set K8S_VERSION and KUBECONFIG    
    docker run \
        --volume=/:/rootfs:ro \
        --volume=/sys:/sys:ro \
        --volume=/var/lib/docker/:/var/lib/docker:rw \
        --volume=/var/lib/kubelet/:/var/lib/kubelet:rw \
        --volume=/var/run:/var/run:rw \
        --net=host \
        --pid=host \
        --privileged=true \
        --name=kubelet \${K8S_VERSION} \
        /hyperkube kubelet \
            --containerized \
            --hostname-override="" \
            --address="" \
            --api-servers=http://localhost:8080 \
            --config=/etc/kubernetes/manifests \
            --cluster-dns= \
            --cluster-domain=cluster.local \
            --allow-privileged=true --v=2

    And that seems to work, judging by the docker logs.

    My problem is that I can’t run kubectl on my docker host. If I set

    - cluster:
        server: http://<docker-machine ip mydocker>:8080

    I get connection refused.

    If I set up port forwarding by running VBoxManage controlvm "$DOCKER_MACHINE_NAME" natpf1 "tcp-port8080,tcp,,8080,,8080" and then try to connect with server: http://localhost:8080, then I get Unable to connect to the server: EOF.

    If I docker-machine ssh mydocker then I can see that the api-server container has port 8080 bound to, so I can’t connect over the network. If I could configure it to bind to then I should be able to connect via port forwarding or by the ip address, I would think. If that will work, how do I configure that? Is there another solution I’m missing?

  • Docker 1.12 Swarm Service External IP
  • Dockerfile - How to pass an answer to a prompt post apt-get install?
  • Hadoop Cluster distributed in different sub-networks (Docker + Flannel)
  • how to diagnose 404 not found error nginx on docker?
  • Exception on reloading remote spring boot application with Intellij IDEA
  • My docker container isn't starting on localhost ( on Docker for Windows (Native using Hyper-V)
  • Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.