Skip to content
This repository was archived by the owner on Jul 18, 2025. It is now read-only.

Commit 6c477ba

Browse files
authored
Merge pull request #417 from vdemeester/319-create-default-network-if-required
Create the default network if required.
2 parents c675395 + 18dad7c commit 6c477ba

File tree

4 files changed

+16
-2
lines changed

4 files changed

+16
-2
lines changed

docker/network/network.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,12 @@ func NetworksFromServices(cli client.NetworkAPIClient, projectName string, netwo
169169
networkNames[network.Name] = network
170170
}
171171
}
172+
if len(networkConfigs) == 0 {
173+
network := NewNetwork(projectName, "default", &config.NetworkConfig{
174+
Driver: "bridge",
175+
}, cli)
176+
networks = append(networks, network)
177+
}
172178
for name, config := range networkConfigs {
173179
network := NewNetwork(projectName, name, config, cli)
174180
networks = append(networks, network)

docker/network/network_test.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,12 @@ func TestNetworksFromServices(t *testing.T) {
3434
expectedError bool
3535
}{
3636
{
37-
expectedNetworks: []*Network{},
37+
expectedNetworks: []*Network{
38+
{
39+
name: "default",
40+
projectName: "prj",
41+
},
42+
},
3843
},
3944
{
4045
networkConfigs: map[string]*config.NetworkConfig{

integration/volume_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ func (s *CliSuite) TestNamedVolume(c *C) {
7777
}
7878

7979
func (s *CliSuite) TestV2Volume(c *C) {
80+
testRequires(c, not(DaemonVersionIs("1.9")))
8081
p := s.ProjectFromText(c, "up", `version: "2"
8182
services:
8283
with_volume:

project/project.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,10 +267,12 @@ func (p *Project) handleNetworkConfig() {
267267
serviceConfig.Networks = &yaml.Networks{
268268
Networks: []*yaml.Network{
269269
{
270-
Name: "default",
270+
Name: "default",
271+
RealName: fmt.Sprintf("%s_%s", p.Name, "default"),
271272
},
272273
},
273274
}
275+
p.AddNetworkConfig("default", &config.NetworkConfig{})
274276
}
275277
// Consolidate the name of the network
276278
// FIXME(vdemeester) probably shouldn't be there, maybe move that to interface/factory

0 commit comments

Comments
 (0)