Docker – 在swarmpipe理器上运行应用程序(无法连接)

TLDR版本:

我如何validation/设置我的群集节点上的端口7946&4789,以便我可以查看我的泊坞窗机器上运行的应用程序?

完整的问题:

我正在通过docker教程,并在第4步https://docs.docker.com/get-started/part4/#accessing-your-cluster

当我开始访问您的群集部分。 它说,我应该能够从使用docker-machine ls显示的一个节点中获取IP地址。 我运行该命令,看到IP,抓住它,并将其放入我的浏览器(或使用curl),我收到错误

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 

在这一步下面有一个说明,说明在启用swarm模式之前,假设它们是在运行时的意思:

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

您应该检查以下端口设置

 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. 

我花了几天的时间阅读文档,重做了这些步骤,并尽我所能去完成这项工作,但没有成功。

任何人都可以解释/提供文件,告诉我如何查看/设置这些端口,或解释我是否缺less一些其他重要信息?

UPDATE

我无法获得swarm的工作,所以我决定只运行docker-compose.yml文件中的所有东西。 以下是我在下面使用的代码:

docker-compose.yml文件:

 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 

和位于同一目录中的Dockerfile,其中包含以下内容:

 # 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 

您需要创build这两个文件中引用的其他文件(例如requirements.txt&index.py),但这些文件与dockerfile&docker-compose.yml文件都在同一目录中。 如果有人有问题,请发表评论