I've been following this tutorial on getting started with Kubernetes using Docker containers, which is a variation of this official tutorial modified to use docker-compose
.
I've managed to get as far as listing the nodes using
kubectl get nodes
but I can only do that if I have an SSH connection open to the container in another window, opened using
docker-machine ssh docker-vm -L 8080:localhost:8080
This is quite messy and I'd like to be able to handle this in the docker-compose.yml
, but I don't know how
I've tried using the ports
and expose
options in the iml file, but they do not work. When I try to forward/expose port 8080 and get the nodes using the above kubectl
command, I get the following error:
error: couldn't read version from server: Get http://localhost:8080/api: EOF
I've used the docker-compose.yml
from the first link at the top, and made the following modifications:
aipserver:
ports:
- "8080:8080"
expose:
- "8080"
I've tried this on all of the containers specified in the docker-compose.yml
, but the problem persists.
How can I use the docker-compose.yml
to forward/expose ports on my containers without having to open an SSH connection with the -L
option specified.
Best Answer
The API server is exposed on the host network on 127.0.0.1:8080
If you want to expose it on the docker-machine vm you need to change the --address flag to be --address=0.0.0.0:8080 instead of --address=127.0.0.1:8080
That will expose it on the VM's address on your machine (e.g. 1.2.3.4)
If you have virtual box port-forwarding set up correctly, this will also make it available at localhost:8080 on your machine.