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

connect to external networks by name #12234

Merged
merged 1 commit into from
Oct 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion pkg/compose/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -1363,7 +1363,6 @@ func (s *composeService) resolveExternalNetwork(ctx context.Context, n *types.Ne

switch len(networks) {
case 1:
n.Name = networks[0].ID
return nil
case 0:
enabled, err := s.isSWarmEnabled(ctx)
Expand Down
6 changes: 2 additions & 4 deletions pkg/e2e/watch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,8 @@ func TestRebuildOnDotEnvWithExternalNetwork(t *testing.T) {
errors)
}, 30*time.Second, 1*time.Second)

n := c.RunDockerCmd(t, "network", "inspect", networkName, "-f", "{{ .Id }}")
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")
err = os.WriteFile(dotEnvFilepath, []byte("HELLO=WORLD\nTEST=REBUILD"), 0o666)
Expand All @@ -119,9 +118,8 @@ func TestRebuildOnDotEnvWithExternalNetwork(t *testing.T) {
return true, fmt.Sprintf("container %s was rebuilt", containerName)
}, 30*time.Second, 1*time.Second)

n2 := c.RunDockerCmd(t, "network", "inspect", networkName, "-f", "{{ .Id }}")
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"))

Expand Down
Loading