connect to external networks by name
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
This commit is contained in:
parent
a4ee6ca7a5
commit
aa1ec4524c
@ -1363,7 +1363,6 @@ func (s *composeService) resolveExternalNetwork(ctx context.Context, n *types.Ne
|
|||||||
|
|
||||||
switch len(networks) {
|
switch len(networks) {
|
||||||
case 1:
|
case 1:
|
||||||
n.Name = networks[0].ID
|
|
||||||
return nil
|
return nil
|
||||||
case 0:
|
case 0:
|
||||||
enabled, err := s.isSWarmEnabled(ctx)
|
enabled, err := s.isSWarmEnabled(ctx)
|
||||||
|
@ -99,9 +99,8 @@ func TestRebuildOnDotEnvWithExternalNetwork(t *testing.T) {
|
|||||||
errors)
|
errors)
|
||||||
}, 30*time.Second, 1*time.Second)
|
}, 30*time.Second, 1*time.Second)
|
||||||
|
|
||||||
n := c.RunDockerCmd(t, "network", "inspect", networkName, "-f", "{{ .Id }}")
|
|
||||||
pn := c.RunDockerCmd(t, "inspect", containerName, "-f", "{{ .HostConfig.NetworkMode }}")
|
pn := c.RunDockerCmd(t, "inspect", containerName, "-f", "{{ .HostConfig.NetworkMode }}")
|
||||||
assert.Equal(t, pn.Stdout(), n.Stdout())
|
assert.Equal(t, strings.TrimSpace(pn.Stdout()), networkName)
|
||||||
|
|
||||||
t.Log("create a dotenv file that will be used to trigger the rebuild")
|
t.Log("create a dotenv file that will be used to trigger the rebuild")
|
||||||
err = os.WriteFile(dotEnvFilepath, []byte("HELLO=WORLD\nTEST=REBUILD"), 0o666)
|
err = os.WriteFile(dotEnvFilepath, []byte("HELLO=WORLD\nTEST=REBUILD"), 0o666)
|
||||||
@ -119,9 +118,8 @@ func TestRebuildOnDotEnvWithExternalNetwork(t *testing.T) {
|
|||||||
return true, fmt.Sprintf("container %s was rebuilt", containerName)
|
return true, fmt.Sprintf("container %s was rebuilt", containerName)
|
||||||
}, 30*time.Second, 1*time.Second)
|
}, 30*time.Second, 1*time.Second)
|
||||||
|
|
||||||
n2 := c.RunDockerCmd(t, "network", "inspect", networkName, "-f", "{{ .Id }}")
|
|
||||||
pn2 := c.RunDockerCmd(t, "inspect", containerName, "-f", "{{ .HostConfig.NetworkMode }}")
|
pn2 := c.RunDockerCmd(t, "inspect", containerName, "-f", "{{ .HostConfig.NetworkMode }}")
|
||||||
assert.Equal(t, pn2.Stdout(), n2.Stdout())
|
assert.Equal(t, strings.TrimSpace(pn2.Stdout()), networkName)
|
||||||
|
|
||||||
assert.Check(t, !strings.Contains(r.Combined(), "Application failed to start after update"))
|
assert.Check(t, !strings.Contains(r.Combined(), "Application failed to start after update"))
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user