<pre><code>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 \
    -d \
    gcr.io/google_containers/hyperkube-amd64:v${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
</code></pre>

<p>A <code>curl localhost:8080</code>confirms that the API is running.</p>

<p>But trying to access it with the host's IP like <code>curl dockerHostIp:8080</code>fails:</p>

<pre><code>Failed to connect to ipOfDockerHost port 8080: Connection refused
</code></pre>

<p>How can I expose k8s to the outside? (docker-host is an ubuntu server)
As far as I understand using --net=host should solve this problem. But it does not work in this case.</p>

<p>When you start kubernetes with docker, you choose between two models:</p>

<ul>
<li><a href="https://github.com/kubernetes/kubernetes/blob/master/cluster/images/hyperkube/master.json" rel="nofollow">--config=/etc/kubernetes/manifests</a> </li>
<li><a href="https://github.com/kubernetes/kubernetes/blob/master/cluster/images/hyperkube/master-multi.json" rel="nofollow">--config=/etc/kubernetes/manifests-multi</a>.</li>
</ul>

<p>If you look in these files, you will notice one difference: <code>--insecure-bind-address is different</code>.</p>

<p>When you use <code>--config=/etc/kubernetes/manifests</code>, you ask for a local access only.</p>

<p>You should start with <code>--config=/etc/kubernetes/manifests-multi</code>.</p>

<p>Note that:</p>

<ul>
<li>you will need to start etcd manually when you use --config=/etc/kubernetes/manifests-multi</li>
<li>follow <a href="https://github.com/kubernetes/kubernetes/issues/4869" rel="nofollow">this post</a> as docker support is not working for now</li>
</ul>
