mirror of
https://github.com/docker/cli.git
synced 2026-01-15 07:40:57 +03:00
Few stack deploy network fixes
- Make sure we use the correct network name for external ones. - Make the default network overridable and only creates networks that are used by services — so that default network is only created if a service doesn't declare a network. Signed-off-by: Vincent Demeester <vincent@sbr.pm>
This commit is contained in:
@@ -117,7 +117,9 @@ func deployCompose(ctx context.Context, dockerCli *command.DockerCli, opts deplo
|
||||
|
||||
namespace := convert.NewNamespace(opts.namespace)
|
||||
|
||||
networks, externalNetworks := convert.Networks(namespace, config.Networks)
|
||||
serviceNetworks := getServicesDeclaredNetworks(config.Services)
|
||||
|
||||
networks, externalNetworks := convert.Networks(namespace, config.Networks, serviceNetworks)
|
||||
if err := validateExternalNetworks(ctx, dockerCli, externalNetworks); err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -131,6 +133,20 @@ func deployCompose(ctx context.Context, dockerCli *command.DockerCli, opts deplo
|
||||
return deployServices(ctx, dockerCli, services, namespace, opts.sendRegistryAuth)
|
||||
}
|
||||
|
||||
func getServicesDeclaredNetworks(serviceConfigs []composetypes.ServiceConfig) map[string]struct{} {
|
||||
serviceNetworks := map[string]struct{}{}
|
||||
for _, serviceConfig := range serviceConfigs {
|
||||
if len(serviceConfig.Networks) == 0 {
|
||||
serviceNetworks["default"] = struct{}{}
|
||||
continue
|
||||
}
|
||||
for network := range serviceConfig.Networks {
|
||||
serviceNetworks[network] = struct{}{}
|
||||
}
|
||||
}
|
||||
return serviceNetworks
|
||||
}
|
||||
|
||||
func propertyWarnings(properties map[string]string) string {
|
||||
var msgs []string
|
||||
for name, description := range properties {
|
||||
|
||||
Reference in New Issue
Block a user