title: How to open port 7946 and 4789 in a VM which is created by docker machine
body: <p>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.</p>
  <blockquote>
  <p>Having connectivity trouble?</p>
  <p>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:</p>
  <p>Port 7946 TCP/UDP for container network discovery.</p>
  <p>Port 4789 UDP for the container ingress network.</p>
  </blockquote>
  <p>I have tried to open thes ports in a VM which is created by docker machine. The driver is VirtualBox</p>
  <pre><code>$ docker-machine ssh default
                                          ##         .
                                    ## ## ##        ==
                                 ## ## ## ## ##    ===
                             /&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;\___/ ===
                        ~~~ {~~ ~~~~ ~~~ ~~~~ ~~~ ~ /  ===- ~~~
                             \______ o           __/
                               \    \         __/
                                \____\_______/
                   _                 _   ____     _            _
                  | |__   ___   ___ | |_|___ \ __| | ___   ___| | _____ _ __
                  | '_ \ / _ \ / _ \| __| __) / _` |/ _ \ / __| |/ / _ \ '__|
                  | |_) | (_) | (_) | |_ / __/ (_| | (_) | (__|   &lt;  __/ |
                  |_.__/ \___/ \___/ \__|_____\__,_|\___/ \___|_|\_\___|_|
  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
  </code></pre>
  <p>However these ports cannot be open.
  The following code are written in the /etc/sysconfig/iptables</p>
  <pre><code>-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
  </code></pre>