Home:ALL Converter>Docker - Run app on swarm manager (cant connect)

Docker - Run app on swarm manager (cant connect)

Ask Time:2017-11-13T20:05:15         Author:Jake Boomgaarden

Json Formatter

TLDR version:

How can I verify/set ports 7946 & 4789 on my swarm node so that I can view my application running from my docker-machine?

Complete question:

I am going through the docker tutorials and am on step 4 https://docs.docker.com/get-started/part4/#accessing-your-cluster

When I get to accessing your cluster section. It says that I should just be able to grab the ip address from one of my nodes displayed using docker-machine ls. I run that command, see the IP, grab it and put it into my browser (or alternatively use curl) and i receive the error

This site can’t be reached

192.168.99.100 refused to connect.
Try:
Checking the connection
Checking the proxy and the firewall
ERR_CONNECTION_REFUSED

Below this step it has a note saying that before you enable swarm mode, assuming they mean when you run:

docker-machine ssh myvm1 "docker swarm init --advertise-addr <myvm1 ip>"

You should check the following port settings

Having connectivity trouble?

Keep in mind that in order to use the ingress network in the swarm, you need to have the following ports open between the swarm nodes before you enable swarm mode:

Port 7946 TCP/UDP for container network discovery.
Port 4789 UDP for the container ingress network.

I've spent the last few days going through documentation, redoing the steps and trying everything I can to have this work but nothing has been successful.

Can anyone explain/provide documentation to show me how to view/set these ports, or explain if I am missing some other important information?

UPDATE

I wasn't able to get swarm working, so I decided to just run everything from a docker-compose.yml file. Here is the code I used below:

docker-compose.yml file:

version: '3'
services:
  www:
build: .
ports:
  - "80:80"
links:
  - db
depends_on:
  - db
volumes:
  - .:/opt/www

db:
image: mysql:5.7
volumes:
  - /var/lib/mysql
restart: always
environment:
  MYSQL_ROOT_PASSWORD: supersecure
  MYSQL_DATABASE: test_db
  MYSQL_USER: jake
  MYSQL_PASSWORD: supersecure

and a Dockerfile located in the same directory containing the following:

# A simple Flask app container.
FROM python:2.7
LABEL maintainer="your name here"

# Place app in container.
ADD . /opt/www
WORKDIR /opt/www

# Install dependencies.
RUN pip install -r requirements.txt

EXPOSE 80
ENV FLASK_APP index.py
ENV FLASK_DEBUG 1
CMD python index.py

you'll need to create any other files which are referenced in these two files (example requirements.txt & index.py) but those are all in the same directory as the dockerfile & docker-compose.yml files. Please comment if anyone has questions

Author:Jake Boomgaarden,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/47263983/docker-run-app-on-swarm-manager-cant-connect
yy