I have a docker swarm with currently just one node and a few stacks. To be able to get the ip-address of the client requesting one of my services I switched the port on one service to mode:host. This works fine except when I want to update that service. I didn't change the deploy-order so it should be the default 'stop-first' but when I use stack deploy
the tasks failes with the following message:
no suitable node (host-mode port already in use on 1 node)
When I scale down the service to 0 and then use stack deploy
it works without problem but I don't understand why it becomes a problem when updating directly. Shouldn't "stop-first" mean, that the old service is killed first (freeing up the port) and then the new service is started?
How can I change the yml without having to scale to 0 before deploying the change?
this is the application.yml in question:
version: "3.7"
services:
myservice:
image: myrepo/gateway
ports:
- mode: host
protocol: tc
published: 443
target: 443
networks:
- gateway_net
networks:
gateway_net:
external: true # was created with 'docker network create -d overlay gateway_net', is used to connect gw with other services