How to open port 7946 and 4789 in a VM which is created by docker machine

Hello.
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:
Port 7946 TCP/UDP for container network discovery.
Port 4789 UDP for the container ingress network.

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

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

Did you ever solve this issue? I am experiencing the exact same thing.

1 Like

have the same issue, waiting for the update

I have the same question.

Same problem for me , any news available on this subject ?

Same here, anyone resolve this?

Hi, attempting to work through this exact same issue today - does anyone have anything further, or possibly reference to other documentation?

Update: Gave up on trying to make this work with local virtual machines, got a free Azure account and moved on to Part 6 and it worked on cloud swarm when I set up the ports as described there (well except for the Redis counter - need to figure out why that’s not working).

I’m having the same issue as well.

If you are following the tutorial, make sure to use the port specified in your docker-compose.yml. So you enter this in the browser instead of just the IP of your vm as shown in the tutorial:
http://192.168.99.100:4000