Configure the Linux Firewall for Docker Swarm on Ubuntu

15 Dec 2017

Share to:

บทความนี้จะเกี่ยวข้องกับการ Config Linux Firewall ให้สามารถใช้งาน Docker swarm ได้ ถ้าไม่ได้ Config เราจะเจอกับ Error นี้ “Timeout was reached before node was joined. The attempt to join the swarm will continue in the background. Use the “docker info” command to see the current swarm status of your node.” ในขั้นตอนการ Join Swarm เพราะว่า Docker Swarm ใช้งาน port ดังต่อไปนี้

  • TCP port 2376 for secure Docker client communication. This port is required for Docker Machine to work. Docker Machine is used to orchestrate Docker hosts.
  • TCP port 2377. This port is used for communication between the nodes of a Docker Swarm or cluster. It only needs to be opened on manager nodes.
  • TCP and UDP port 7946 for communication among nodes (container network discovery).
  • UDP port 4789 for overlay network traffic (container ingress networking).

ดังนั้นเราจึงต้องไป config firewall เพื่อให้สามารถใช้งานได้ มีขั้นตอนดังนี้ ใช้คําสั่งตามลําดับดังนี้ได้เลยครับ

ufw allow 22/tcp
ufw allow 2376/tcp
ufw allow 2377/tcp
ufw allow 7946/tcp
ufw allow 7946/udp
ufw allow 4789/udp

reload UFW ด้วยคําสั่ง

ufw reload

Enable UFW ด้วยคําสั่ง

ufw enable

Restart docker engin

systemctl restart docker

เท่านี้เราก็สามารถใช้งาน Docker Swarm ได้แล้วครับ :)


Copyright © 2024 thiti.dev |  v1.16.0 |  Privacy policy |  status | 

            วงแหวนเว็บ