Skip to content

Allow scaling services with static ports on Swarm with affinity #1378

@frol

Description

@frol

Please, look at this config:

mynode:
    image: myimage
    environment:
        - "affinity:container!=myproject_mynode_*"
    ports:
        - "50010:50010"

Once I try to scale it with docker-compose scale mynode=3 it rejects to scale with the following error:

Service "mynode" cannot be scaled because it specifies a port on the host. If multiple containers for this service were created, the port would clash.

Remove the ":" from the port definition in docker-compose.yml so Docker can choose a random port for each container.

However, the ports won't clash because of the affinity.

Now, I'm forced to use net: host to avoid this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions