Docker Community Forums

Share and learn in the Docker community.

Swarm does not accept connection if running on VM (created by docker-machine)


#1

Hello! Happy New Year!
I am learning docker through great tutorial https://docs.docker.com/get-started/part3/.
Everything from there is understandable.
But I cannot get working swarm on virtual machine created with command

docker-machine create --driver virtualbox myvm1

Shortly what does works and what does not.
DOES WORK

  • IT DOES WORK: swarm created on my local physical machine with commands with usual commands:

docker swarm init --advertise-addr 192.168.0.75
docker stack deploy -c docker-compose.yml getstartedlab

  • IT DOES WORK: single docker image run on created virtual machine

docker-machine create --driver virtualbox myvm1
docker-machine ssh myvm1
docker pull aeuo/get-started:part2
docker run -p 80:80 aeuo/get-started:part2

BUT DOES NOT WORK

  • IT DOES NOT WORK: swarm docker run on created virtual machine

docker-machine ssh myvm1
docker swarm init --advertise-addr 192.168.99.103
cd /hosthome/alek/docker/get-started/
docker stack deploy -c docker-compose.yml getstartedlab

Now logs from VM machine:

docker service logs getstartedlab_web
getstartedlab_web.2.s293w68tanfa@myvm1 | * Serving Flask app “app” (lazy loading)
getstartedlab_web.2.s293w68tanfa@myvm1 | * Environment: production
getstartedlab_web.2.s293w68tanfa@myvm1 | WARNING: Do not use the development server in a production environment.
getstartedlab_web.2.s293w68tanfa@myvm1 | Use a production WSGI server instead.
getstartedlab_web.2.s293w68tanfa@myvm1 | * Debug mode: off
getstartedlab_web.2.s293w68tanfa@myvm1 | * Running on http://0.0.0.0:80/ (Press CTRL+C to quit)

sudo netstat -npat
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 2282/sshd
tcp 0 304 10.0.2.15:22 10.0.2.2:34932 ESTABLISHED 2756/sshd: docker

tcp 0 0 :::80 :::* LISTEN 2611/dockerd

tcp 0 0 :::22 :::* LISTEN 2282/sshd
tcp 0 0 :::2376 :::* LISTEN 2611/dockerd
tcp 0 0 :::2377 :::* LISTEN 2611/dockerd
tcp 0 0 :::7946 :::* LISTEN 2611/dockerd

As you can see service is UP, BUT
curl localhost
curl: (7) Failed to connect to localhost port 80: Connection refused

Single container does work but swarm of containers does not. :frowning:
So tutorial is broken on part 4.
In which direction I can dig else?


Docker swarm nodes not responding
Docker swarm nodes not responding
#2

Hi, I had the same issue with the boot2docker iso v18.09

if you download the v18.09.1-rc1 iso from GitHub it works

btw the url is https://github.com/boot2docker/boot2docker/releases/

I had to use --hyperv-boot2docker-url file://pathto/boot2docker.iso to get it working

Andrew


#3

Thanks you, Andrew. v18.09-1-rc1 works for me too!
If someone needs to create virtual machine specifying different release from default then please use next command

docker-machine create --driver virtualbox --virtualbox-boot2docker-url https://github.com/boot2docker/boot2docker/releases/download/v18.09.1-rc1/boot2docker.iso myvm1


#4

Doh, didn’t think about using an url rather than a file path :slight_smile: