Trouble connecting to my docker app via VM IP

360 views Asked by At

Solved at bottom

But why do I have to append :4000?


I'm following the docker get-started Guide here, https://docs.docker.com/get-started/part4/

I'm fairly certain I've done everything correctly, but am wondering why I can't connect to view the app after deploying it.

I've set my env to my VM, myvm1, for reference to following commands.

docker container ls -a

CONTAINER ID        IMAGE                          COMMAND             CREATED             STATUS              PORTS               NAMES
099e16249604        beresj/getting-started:part2   "python app.py"     12 seconds ago      Up 12 seconds       80/tcp              getstartedlab_web.5.y0e2k1r1ev47u24e5iufkyn3i
6f9a24b343a7        beresj/getting-started:part2   "python app.py"     12 seconds ago      Up 12 seconds       80/tcp              getstartedlab_web.3.1pls3osj3uhsb5dyqtt4ts8j6

docker image ls -a

REPOSITORY               TAG                 IMAGE ID            CREATED             SIZE
beresj/getting-started   <none>              e290b6208c21        22 hours ago        131MB

docker stack ls

NAME                SERVICES            ORCHESTRATOR
getstartedlab       1                   Swarm

docker-machine ls

NAME    ACTIVE   DRIVER       STATE     URL                         SWARM   DOCKER     ERRORS
myvm1   *        virtualbox   Running   tcp://192.168.99.100:2376           v18.09.6   
myvm2   -        virtualbox   Running   tcp://192.168.99.101:2376           v18.09.6  

docker stack ps getstartedlab

ID                  NAME                  IMAGE                          NODE                DESIRED STATE       CURRENT STATE           ERROR               PORTS
vkxx79fh3h85        getstartedlab_web.1   beresj/getting-started:part2   myvm2               Running             Running 3 minutes ago                       
qexbaa3wz0pd        getstartedlab_web.2   beresj/getting-started:part2   myvm2               Running             Running 3 minutes ago                       
1pls3osj3uhs        getstartedlab_web.3   beresj/getting-started:part2   myvm1               Running             Running 3 minutes ago                       
ucuwen1jrncf        getstartedlab_web.4   beresj/getting-started:part2   myvm2               Running             Running 3 minutes ago                       
y0e2k1r1ev47        getstartedlab_web.5   beresj/getting-started:part2   myvm1               Running             Running 3 minutes ago     

curl 192.168.99.100

curl: (7) Failed to connect to 192.168.99.100 port 80: Connection refused

docker info

Containers: 2
 Running: 2
 Paused: 0
 Stopped: 0
Images: 1
Server Version: 18.09.6
...
Swarm: active
 NodeID: 0p9qrax9h3by0fupat8ufkfbq
 Is Manager: true
 ClusterID: 7vnqdk85n8jx6fqck9k7dv2ka
 Managers: 1
 Nodes: 2
 Default Address Pool: 10.0.0.0/8  
...
Node Address: 192.168.99.100
 Manager Addresses:
  192.168.99.100:2377
...
Kernel Version: 4.14.116-boot2docker
Operating System: Boot2Docker 18.09.6 (TCL 8.2.1)
OSType: linux
Architecture: x86_64
CPUs: 1
Total Memory: 989.4MiB
Name: myvm1

I would expect to see what I was able to see when I just ran it on my local machine instead of on a VM in a swarm (I think I have the lingo correct?)

Not sure how to check open ports.
Again: this works if I simply remove the stack, unset the docker-machine environment, and just run:
docker stack deploy -c docker-compose.yml getstartedlab
not on the vm.

Thank you in advance. (Also, I'm new hence the get-started guide so I appreciate any help)

Edit

It works if I append :4000 to the VM IP in my url, ex: 192.168.99.100:4000 or 192.168.99.101:4000. It shows the two container Id's listed in 'docker container ls' for myvm1, and the other three are from myvm2. Could anyone tell me why I have to append 4000? Is it because I have ports: "4000:80" in my docker-compose.yml?

1

There are 1 answers

3
Dante On

Not sure if this will help but if you use docker inspect <instance_id_here>, you can see what ports are exposed.

Exposed ports aren't open ports. You would need to bind a host port to a container port in the docker-compose.yml in order for it to be to be open.