如何在由docker机器创建的VM中打开端口7946和4789 [英] How to open port 7946 and 4789 in a VM which is created by docker machine

查看:211
本文介绍了如何在由docker机器创建的VM中打开端口7946和4789的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在研究 Docker入门,第4部分。我的操作系统是Win10 64x。
我的应用程序无法通过网络浏览器访问。我从文档中找到了可能的原因。

I’m working through "Get Started with Docker", Part 4. My OS is Win10 64x. My app cannot be accessed through a web browser. I found a possible reason from the document.


遇到连接问题吗?

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:

用于容器网络发现的端口7946 TCP / UDP。

Port 7946 TCP/UDP for container network discovery.

用于容器入口网络的端口4789 UDP。

Port 4789 UDP for the container ingress network.

我试图在由docker创建的VM中打开这些端口机。驱动程序是VirtualBox

I have tried to open thes ports in a VM which is created by docker machine. The driver is VirtualBox

$ docker-machine ssh default
                                        ##         .
                                  ## ## ##        ==
                               ## ## ## ## ##    ===
                           /"""""""""""""""""\___/ ===
                      ~~~ {~~ ~~~~ ~~~ ~~~~ ~~~ ~ /  ===- ~~~
                           \______ o           __/
                             \    \         __/
                              \____\_______/
                 _                 _   ____     _            _
                | |__   ___   ___ | |_|___ \ __| | ___   ___| | _____ _ __
                | '_ \ / _ \ / _ \| __| __) / _` |/ _ \ / __| |/ / _ \ '__|
                | |_) | (_) | (_) | |_ / __/ (_| | (_) | (__|   <  __/ |
                |_.__/ \___/ \___/ \__|_____\__,_|\___/ \___|_|\_\___|_|
Boot2Docker version 17.09.1-ce, build HEAD : e7de9ae - Fri Dec  8 19:41:36 UTC 2017
Docker version 17.09.1-ce, build 19e2cf6    
docker@default:~$ sudo -i
Boot2Docker version 17.09.1-ce, build HEAD : e7de9ae - Fri Dec  8 19:41:36 UTC 2017
Docker version 17.09.1-ce, build 19e2cf6
root@default:~# firewall-cmd --z one=public --add-port=7946/tcp --permanent
-sh: firewall-cmd: not found
root@default:~#  vi /etc/sysconfig/iptables
root@default:~# service iptables restart
-sh: service: not found
root@default:~# source /etc/sysconfig/iptables
-sh: /etc/sysconfig/iptables: line 1: -A: not found
-sh: /etc/sysconfig/iptables: line 2: -A: not found
root@default:~#  vi /etc/sysconfig/iptables
root@default:~# service iptables status
-sh: service: not found
root@default:~# yum install firewalld firewalld-config
-sh: yum: not found
root@default:~# apt get firewalld firewalld-config
-sh: apt: not found

但是这些端口无法打开。
以下代码写在/ etc / sysconfig / iptables

However these ports cannot be open. The following code are written in the /etc/sysconfig/iptables

-A INPUT -p tcp -m state --state NEW -m tcp --dport 7946 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 4789 -j ACCEPT


推荐答案

我在这里遇到了相同的问题。
我实际上没有到达正确的端口。
在教程的第一部分中,Web应用程序位于端口4000上。
尝试执行此操作,或更新docker-compose文件将端口80重定向至80。

I've encountered the same issue here. I was actually not hitting the right port. In the first part of the tutorial, the webapp is on the port 4000. Try this, or update the docker-compose file to redirect the port 80 to 80.

这篇关于如何在由docker机器创建的VM中打开端口7946和4789的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆