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

Commit 18dad7c

Browse files
committed
Create the default network if required.
Signed-off-by: Vincent Demeester <[email protected]>
1 parent d37dc41 commit 18dad7c

File tree

4 files changed

+17
-3
lines changed

4 files changed

+17
-3
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: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ func (p *Project) CreateService(name string) (Service, error) {
160160
parts := strings.SplitN(envValue[0], "=", 2)
161161
config.Build.Args[parts[0]] = parts[1]
162162
default:
163-
return nil, fmt.Errorf("Tried to set Build Arg %#v to multi-value %#v.", arg, envValue)
163+
return nil, fmt.Errorf("tried to set Build Arg %#v to multi-value %#v", arg, envValue)
164164
}
165165
}
166166
}
@@ -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)