Skip to content

Commit

Permalink
Additional Docker Compose Run Flags (#443)
Browse files Browse the repository at this point in the history
  • Loading branch information
ethanleifer authored Jun 17, 2023
1 parent d2d6070 commit 730c48a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
2 changes: 2 additions & 0 deletions python_on_whales/components/compose/cli_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -499,6 +499,7 @@ def run(
self,
service: str,
command: List[str] = [],
build: bool = False,
detach: bool = False,
# entrypoint: Optional[List[str]] = None,
# envs: Dict[str, str] = {},
Expand Down Expand Up @@ -563,6 +564,7 @@ def run(
"Try setting tty=False in docker.compose.run(...)."
)
full_cmd = self.docker_compose_cmd + ["run"]
full_cmd.add_flag("--build", build)
full_cmd.add_flag("--detach", detach)
full_cmd.add_simple_arg("--name", name)
full_cmd.add_flag("--no-TTY", not tty)
Expand Down
11 changes: 11 additions & 0 deletions tests/python_on_whales/components/test_compose.py
Original file line number Diff line number Diff line change
Expand Up @@ -860,3 +860,14 @@ def test_docker_compose_up_remove_orphans():
docker.compose.down(timeout=1)
check_number_of_running_containers(docker, 0, compose_container_ids)
remove(compose_file)


def test_docker_compose_run_build():
docker.compose.run("my_service", build=True, detach=True, tty=False)
docker.compose.stop()
docker.compose.rm()
assert (
docker.compose.config(return_json=True)["services"]["my_service"]["image"]
== docker.image.list("some_random_image")[0].repo_tags[0].split(":latest")[0]
)
docker.image.remove("some_random_image", force=True)

0 comments on commit 730c48a

Please sign in to comment.