Bring up all dependencies when running a single service.

Added test for running a depends_on service

Signed-off-by: Joffrey F <joffrey@docker.com>
This commit is contained in:
Joffrey F 2016-02-11 16:31:08 -08:00
parent 77cf67ba8a
commit 367fabdbfa
3 changed files with 23 additions and 1 deletions

View File

@ -686,7 +686,7 @@ def image_type_from_opt(flag, value):
def run_one_off_container(container_options, project, service, options):
if not options['--no-deps']:
deps = service.get_linked_service_names()
deps = service.get_dependency_names()
if deps:
project.up(
service_names=deps,

View File

@ -738,6 +738,15 @@ class CLITestCase(DockerClientTestCase):
self.assertEqual(len(db.containers()), 1)
self.assertEqual(len(console.containers()), 0)
@v2_only()
def test_run_service_with_dependencies(self):
self.base_dir = 'tests/fixtures/v2-dependencies'
self.dispatch(['run', 'web', '/bin/true'], None)
db = self.project.get_service('db')
console = self.project.get_service('console')
self.assertEqual(len(db.containers()), 1)
self.assertEqual(len(console.containers()), 0)
def test_run_with_no_deps(self):
self.base_dir = 'tests/fixtures/links-composefile'
self.dispatch(['run', '--no-deps', 'web', '/bin/true'])

View File

@ -0,0 +1,13 @@
version: "2.0"
services:
db:
image: busybox:latest
command: top
web:
image: busybox:latest
command: top
depends_on:
- db
console:
image: busybox:latest
command: top