diff --git a/python_on_whales/components/compose/cli_wrapper.py b/python_on_whales/components/compose/cli_wrapper.py index 877c9b19..4e863d67 100644 --- a/python_on_whales/components/compose/cli_wrapper.py +++ b/python_on_whales/components/compose/cli_wrapper.py @@ -968,6 +968,7 @@ def up( pull: Literal["always", "missing", "never", None] = ..., stream_logs: Literal[True] = ..., wait_timeout: Optional[int] = ..., + dependencies: bool = True, ) -> Iterable[Tuple[str, bytes]]: ... @overload @@ -993,6 +994,7 @@ def up( pull: Literal["always", "missing", "never", None] = ..., stream_logs: Literal[False] = ..., wait_timeout: Optional[int] = ..., + dependencies: bool = True, ) -> None: ... def up( @@ -1017,6 +1019,7 @@ def up( pull: Literal["always", "missing", "never", None] = None, stream_logs: bool = False, wait_timeout: Optional[int] = None, + dependencies: bool = True, ): """Start the containers. @@ -1062,6 +1065,7 @@ def up( See [the streaming guide](https://gabrieldemarmiesse.github.io/python-on-whales/user_guide/docker_run/#stream-the-output) if you are not familiar with the streaming of logs in Python-on-whales. wait_timeout: Maximum duration to wait for the project to be running|healthy + dependencies: Also start linked services. """ if quiet and stream_logs: raise ValueError( @@ -1085,6 +1089,7 @@ def up( full_cmd.add_flag("--no-start", not start) full_cmd.add_flag("--remove-orphans", remove_orphans) full_cmd.add_flag("--renew-anon-volumes", renew_anon_volumes) + full_cmd.add_flag("--no-deps", not dependencies) full_cmd.add_simple_arg("--pull", pull) if no_attach_services is not None: diff --git a/tests/python_on_whales/components/test_compose.py b/tests/python_on_whales/components/test_compose.py index 59bf9d58..ba06918f 100644 --- a/tests/python_on_whales/components/test_compose.py +++ b/tests/python_on_whales/components/test_compose.py @@ -190,6 +190,32 @@ def test_docker_compose_up_down(): assert docker.compose.ps() == [] +@pytest.mark.parametrize( + "dependencies_value, expected_running_containers", [(True, 2), (False, 1)] +) +def test_docker_compose_up_dependencies( + dependencies_value, expected_running_containers +): + docker = DockerClient( + compose_files=[ + PROJECT_ROOT / "tests/python_on_whales/components/dummy_compose.yml" + ], + compose_compatibility=True, + ) + + try: + docker.compose.up( + ["busybox-2-electric-boogaloo"], + dependencies=dependencies_value, + detach=True, + ) + running_containers = docker.compose.ps() + finally: + docker.compose.down(timeout=1) + + assert len(running_containers) == expected_running_containers + + def test_docker_compose_up_down_streaming(): docker = DockerClient( compose_files=[