mirror of https://github.com/docker/compose.git
Remove ability to join bridge network + user-defined networks
Containers connected to the bridge network can't have aliases, so it's simpler to rule that they can *either* be connected to the bridge network (via `network_mode: bridge`) *or* be connected to user-defined networks (via `networks` or the default network). Signed-off-by: Aanand Prasad <aanand.prasad@gmail.com>
This commit is contained in:
parent
e69ef1c456
commit
650b0cec38
|
@ -470,16 +470,13 @@ def get_networks(service_dict, network_definitions):
|
|||
|
||||
networks = []
|
||||
for name in service_dict.pop('networks', ['default']):
|
||||
if name in ['bridge']:
|
||||
networks.append(name)
|
||||
matches = [n for n in network_definitions if n.name == name]
|
||||
if matches:
|
||||
networks.append(matches[0].full_name)
|
||||
else:
|
||||
matches = [n for n in network_definitions if n.name == name]
|
||||
if matches:
|
||||
networks.append(matches[0].full_name)
|
||||
else:
|
||||
raise ConfigurationError(
|
||||
'Service "{}" uses an undefined network "{}"'
|
||||
.format(service_dict['name'], name))
|
||||
raise ConfigurationError(
|
||||
'Service "{}" uses an undefined network "{}"'
|
||||
.format(service_dict['name'], name))
|
||||
return networks
|
||||
|
||||
|
||||
|
|
|
@ -472,11 +472,6 @@ Networks to join, referencing entries under the
|
|||
- some-network
|
||||
- other-network
|
||||
|
||||
The value `bridge` can also be used to make containers join the pre-defined
|
||||
`bridge` network.
|
||||
|
||||
There is no equivalent to `net: "container:[name or id]"`.
|
||||
|
||||
### pid
|
||||
|
||||
pid: "host"
|
||||
|
|
|
@ -495,22 +495,6 @@ class CLITestCase(DockerClientTestCase):
|
|||
|
||||
assert 'Service "web" uses an undefined network "foo"' in result.stderr
|
||||
|
||||
@v2_only()
|
||||
def test_up_with_bridge_network_plus_default(self):
|
||||
filename = 'bridge.yml'
|
||||
|
||||
self.base_dir = 'tests/fixtures/networks'
|
||||
self._project = get_project(self.base_dir, [filename])
|
||||
|
||||
self.dispatch(['-f', filename, 'up', '-d'], None)
|
||||
|
||||
container = self.project.containers()[0]
|
||||
|
||||
assert sorted(list(container.get('NetworkSettings.Networks'))) == sorted([
|
||||
'bridge',
|
||||
self.project.default_network.full_name,
|
||||
])
|
||||
|
||||
@v2_only()
|
||||
def test_up_with_network_mode(self):
|
||||
c = self.client.create_container('busybox', 'top', name='composetest_network_mode_container')
|
||||
|
|
Loading…
Reference in New Issue