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:

  • DockerFile / Switch from ubuntu:latest to alpine:3.3
  • How to scale Docker containers in production
  • Enable JMX in Tomcat docker container
  • Neither “docker stop”, “docker kill” nor “docker -f rm” works
  • e2e testing with docker image standalone-chrome doesn't work without internet access
  • Multiple Python Scripts in Docker
  • .  # 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?

  • How to persist 'ln' in Docker with Ubuntu
  • How do I find a conflicting container that docker reports is not running?
  • Install docker 1.11 on Fedora 21
  • Access to the docker machine from Android app
  • Add docker container to network under two different names
  • CircleCI - Git could not resolve host when cloning repository
  • Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.