mirror of https://github.com/docker/compose.git
Merge pull request #2287 from shin-/2284-ensure-network-exists-run
Ensure network exists when calling run before up
This commit is contained in:
commit
04a76dc284
|
@ -380,6 +380,8 @@ class TopLevelCommand(DocoptCommand):
|
|||
start_deps=True,
|
||||
strategy=ConvergenceStrategy.never,
|
||||
)
|
||||
elif project.use_networking:
|
||||
project.ensure_network_exists()
|
||||
|
||||
tty = True
|
||||
if detach or options['-T'] or not sys.stdin.isatty():
|
||||
|
|
|
@ -508,6 +508,20 @@ class CLITestCase(DockerClientTestCase):
|
|||
container, = service.containers(stopped=True, one_off=True)
|
||||
self.assertEqual(container.name, name)
|
||||
|
||||
@mock.patch('dockerpty.start')
|
||||
def test_run_with_networking(self, _):
|
||||
self.require_api_version('1.21')
|
||||
client = docker_client(version='1.21')
|
||||
self.command.base_dir = 'tests/fixtures/simple-dockerfile'
|
||||
self.command.dispatch(['--x-networking', 'run', 'simple', 'true'], None)
|
||||
service = self.project.get_service('simple')
|
||||
container, = service.containers(stopped=True, one_off=True)
|
||||
networks = client.networks(names=[self.project.name])
|
||||
for n in networks:
|
||||
self.addCleanup(client.remove_network, n['id'])
|
||||
self.assertEqual(len(networks), 1)
|
||||
self.assertEqual(container.human_readable_command, u'true')
|
||||
|
||||
def test_rm(self):
|
||||
service = self.project.get_service('simple')
|
||||
service.create_container()
|
||||
|
|
Loading…
Reference in New Issue