
Halo, kalau kamu merasa tulisan saya ngebantu kamu, kamu bisa ucapkan terima kasih lewat saweria .
If you feel this website help you, you can donate at saweria .
Problem
Client complaint they only can use “network_mode: host” in their swarm environment, it makes they can’t scale their apps
How To Fix The Problem
- First, make sure you have network with overlay driver
#create network
docker network create --driver=overlay app-net-prod
#check new netwokrk
docker network ls

Docker Network
Opened docker swarm communicate port
a. TCP port 2377
b. TCP and UDP port 7946
c. UDP port 4789
If you already setup all of that, but still cannot scale your apps with error “host-mode port already in use on 1 node”.

Scale Failed
Check your compose file, if your network look like this
version: '3.8'
services:
whoami:
image: traefik/whoami
ports:
- target: 2001
published: 2001
mode: host
command:
# It tells whoami to start listening on 2001 instead of 80
- --port=2001
- --name=iamfoo
You just need to remove mode: host
version: '3.8'
services:
whoami:
image: traefik/whoami
ports:
- target: 2001
published: 2001
command:
# It tells whoami to start listening on 2001 instead of 80
- --port=2001
- --name=iamfoo
Then try to scale your app
