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:

  • How do I uninstall docker-compose?
  • Docker-compose open all ports
  • Exposing dynamically opened ports inside docker container
  • Getting “Invalid address” error on gunicorn bind with my server ip . i am trying this within the docker
  • Docker - cannot connect to the Docker daemon
  • Using localhost instead of db for the mysql hostname in docker
  • . docker_kube_env.sh  # 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 \
        gcr.io/google_containers/hyperkube-amd64:${K8S_VERSION} \
        /hyperkube kubelet \
            --containerized \
            --hostname-override="127.0.0.1" \
            --address="0.0.0.0" \
            --api-servers=http://localhost:8080 \
            --config=/etc/kubernetes/manifests \
            --cluster-dns=10.0.0.10 \
            --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

    clusters:
    - 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 127.0.0.1, so I can’t connect over the network. If I could configure it to bind to 0.0.0.0 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?

  • passing command line parameters to spring boot services inside docker container
  • Can I run docker containers linked with different OS
  • Use docker in restricted internet environnement
  • A Docker workflow for a developers team
  • Docker as sandbox environment
  • Execute docker command with deis
  • Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.