
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 can’t update their app on docker swarm cluster with error no suitable node (host-mode port already in use on 1 node)
when they try to update app image.
Here’s their compose file
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
deploy:
#deploy at all server
mode: global
update_config:
parallelism: 1
delay: 10s
order: start-first
failure_action: rollback
placement:
constraints:
- node.platform.os == linux
How To Fix The Problem
It was easy to fix that problem, you can check this github issue page .
We just need to change order to order: stop-first
.
Here’s the full compose file
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
deploy:
#deploy at all server
mode: global
update_config:
parallelism: 1
delay: 10s
#IT MUST USE stop-first!!!
order: stop-first
failure_action: rollback
placement:
constraints:
- node.platform.os == linux
Here’s explanation about that at docker compose docs
order: Order of operations during rollbacks.
One of stop-first (old task is stopped before starting new one).
start-first (new task is started first, and the running tasks briefly overlap) (default stop-first).
It means apps with network_mode: host
cannot killed by new task, they must be stopped, then they will create a new task.