Docker - 在swarm管理器上运行应用程序(无法连接)

时间:2017-11-13 12:05:15

标签: docker cluster-computing docker-swarm docker-machine

TLDR版本:

如何验证/设置端口7946&我的swarm节点上的4789,以便我可以查看从我的docker-machine运行的应用程序?

完整的问题:

我正在浏览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

在此步骤下面有一条说明,说明在启用群集模式之前,假设它们在您运行时的意思:

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.

我花了最后几天浏览文档,重做这些步骤并尽我所能来完成这项工作,但没有任何成功。

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

更新

我无法让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

您需要创建在这两个文件中引用的任何其他文件(例如requirements.txt&amp; index.py),但这些文件都与dockerfile&amp; docker-compose.yml文件。如果有人有疑问,请发表评论

0 个答案:

没有答案
相关问题