Change Forbidden Error (403) to Conflict(409)

Signed-off-by: Arko Dasgupta <arko.dasgupta@docker.com>
(cherry picked from commit 31e8fcc678)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Arko Dasgupta 2019-05-02 22:00:34 -07:00 committed by Sebastiaan van Stijn
parent 275bf7ec03
commit d44a48835f
No known key found for this signature in database
GPG key ID: 76698F39D527CE8C

View file

@ -359,7 +359,8 @@ func (daemon *Daemon) findAndAttachNetwork(container *container.Container, idOrN
networkName := n.Name()
containerName := strings.TrimPrefix(container.Name, "/")
if network, ok := container.NetworkSettings.Networks[networkName]; ok && network.EndpointID != "" {
return n, nil, types.ForbiddenErrorf("%s is already attached to network %s", containerName, networkName)
err := fmt.Errorf("%s is already attached to network %s", containerName, networkName)
return n, nil, errdefs.Conflict(err)
}
}
}