Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix --network-add adding duplicate networks #780

Merged
merged 1 commit into from
Jan 22, 2018

Commits on Jan 9, 2018

  1. Fix --network-add adding duplicate networks

    When adding a network using `docker service update --network-add`,
    the new network was added by _name_.
    
    Existing entries in a service spec are listed by network ID, which
    resulted in the CLI not detecting duplicate entries for the same
    network.
    
    This patch changes the behavior to always use the network-ID,
    so that duplicate entries are correctly caught.
    
    Before this change;
    
        $ docker network create -d overlay foo
        $ docker service create --name=test --network=foo nginx:alpine
        $ docker service update --network-add foo test
        $ docker service inspect --format '{{ json .Spec.TaskTemplate.Networks}}' test
        [
          {
            "Target": "9ot0ieagg5xv1gxd85m7y33eq"
          },
          {
            "Target": "9ot0ieagg5xv1gxd85m7y33eq"
          }
        ]
    
    After this change:
    
        $ docker network create -d overlay foo
        $ docker service create --name=test --network=foo nginx:alpine
        $ docker service update --network-add foo test
        service is already attached to network foo
    
    Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
    thaJeztah committed Jan 9, 2018
    Configuration menu
    Copy the full SHA
    e6ebaf5 View commit details
    Browse the repository at this point in the history