docker - 如何在由 docker 机器创建的 VM 中打开端口 7946 和 4789

标签 docker

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

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.


我试图在由 docker 机器创建的 VM 中打开这些端口。驱动程序是 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
-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

最佳答案

我在这里遇到了同样的问题。
我实际上没有击中正确的端口。
在教程的第一部分中,webapp 位于端口 4000 上。
试试这个,或者更新 docker-compose 文件以将端口 80 重定向到 80。

关于docker - 如何在由 docker 机器创建的 VM 中打开端口 7946 和 4789,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47989962/

相关文章:

shell - Docker:在容器中运行的spigot控制台上执行命令

ssl - 无法登录私有(private) docker registry

docker - 如何在docker-compose.yml中将ARG传递给Dockerfile

Docker 撰写 : Stop "depends_on" service when "parent" finishes

java - 查询正在运行的容器内的数据库

docker - Jenkins Docker引发异常并离线启动

docker - 在 Fedora 23 中更改默认 Docker 镜像下载位置

amazon-web-services - AWS ECS代理在启动时找不到/etc/resolv.conf,也无法将实例添加到ECS集群

docker - Docker子镜像不会继承基础镜像中安装的软件包

apache - 容器刚刚运行后如何执行脚本