0

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?

James B
  • 432
  • 5
  • 22

1 Answers1

1

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.

Dante
  • 548
  • 1
  • 7
  • 19
  • 1
    I actually got a bit of it to work by appending :4000 to the IP (edited in the original question to show this) but not sure where the other three container ID's are coming from since only two show up in docker container ls.. I'm assuming they are from the other vm?... **edit** just verified, they are actually from the other VM. Seems everything was working as expected, I just simply forgot to append the IP w/ :4000. **Thank you though, as that command does help by showing a lot of good info!** – James B Jun 19 '19 at 13:52
  • Follow up, do I have to enter :4000 because ports: - "4000:80" is in my docker-compose.yml? – James B Jun 19 '19 at 14:00
  • Yes, I think you are correct. "4000:80" is binding port 4000 in docker to port 80 on the host as far as I can see. – Dante Jun 19 '19 at 14:53