moby: Swarm mode with mode=host and port is already in use by service on another host.

Hi,

I am using docker swarm mode (1.13) and I have 2 services A and B. Both services publish ports using exclusively mode=host and both services have placement constraint on a different server.

Now the issue is that both services listen of port 443. Once the first service starts, the second is failing to start with the following error:

Error response from daemon: rpc error: code = 3 desc = port '443' is already in use by service 'A' (pjo2sx4wx3apaejqhgevpkvqs)

I am guessing there is a check somewhere that does not take into account that service A is using mode=host and so itโ€™s not mutually exclusive to run services on the same port anymore as far as the services are not running on the same host.

docker version

Client:
 Version:      1.13.0
 API version:  1.25
 Go version:   go1.7.3
 Git commit:   49bf474
 Built:        Tue Jan 17 09:58:26 2017
 OS/Arch:      linux/amd64

Server:
 Version:      1.13.0
 API version:  1.25 (minimum version 1.12)
 Go version:   go1.7.3
 Git commit:   49bf474
 Built:        Tue Jan 17 09:58:26 2017
 OS/Arch:      linux/amd64
 Experimental: false

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 18 (5 by maintainers)

Most upvoted comments

Using stop-first in the deployment config is apparently fairly important to prevent dead-locks on the port when using host most. Service updates will fail with host-mode port already in use on 1 node when start-first is used.

services:
  ftp:
    image: hut6/vsftpd
    ports:
      - { published: 21, target: 21, mode: host }
    deploy:
      mode: global
      update_config:
        order: stop-first

I am guessing there is a check somewhere that does not take into account that service A is using mode=host

Right. checkPortConflicts() must be changed to take that into account.

Has anybody got this to work? I rebuilt from the master and still have the error. I only deployed the dev version to one host. Should I deploy to all? EDIT: stupid me, i did not deploy it on the leader EDIT 2: It works ๐Ÿ‘

Yes, it will be part of the 17.06 release, which is currently near the end of the release candidate phase.