Skip to content

Commit

Permalink
Add entrypoint option to docker.compose.run() (#659) (#661)
Browse files Browse the repository at this point in the history
  • Loading branch information
www84 authored Dec 25, 2024
1 parent 07fe32a commit 86804ee
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
4 changes: 3 additions & 1 deletion python_on_whales/components/compose/cli_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -663,7 +663,7 @@ def run(
command: List[str] = [],
build: bool = False,
detach: bool = False,
# entrypoint: Optional[List[str]] = None,
entrypoint: Optional[str] = None,
# envs: Dict[str, str] = {},
labels: Dict[str, str] = {},
name: Optional[str] = None,
Expand Down Expand Up @@ -691,6 +691,7 @@ def run(
command: The command to execute.
detach: if `True`, returns immediately with the Container.
If `False`, returns the command stdout as string.
entrypoint: The entrypoint to execute.
labels: Add or override labels
name: Assign a name to the container.
dependencies: Also start linked services.
Expand Down Expand Up @@ -728,6 +729,7 @@ def 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("--entrypoint", entrypoint)
full_cmd.add_simple_arg("--name", name)
full_cmd.add_flag("--no-TTY", not tty)
full_cmd.add_flag("--no-deps", not dependencies)
Expand Down
12 changes: 12 additions & 0 deletions tests/python_on_whales/components/test_compose.py
Original file line number Diff line number Diff line change
Expand Up @@ -753,6 +753,18 @@ def test_docker_compose_run_labels():
docker.compose.down(timeout=1)


def test_compose_run_entrypoint():
result = docker.compose.run(
"dodo",
["cmd-is-argument-for-echo"],
entrypoint="/bin/echo",
remove=True,
tty=False,
)

assert result == "cmd-is-argument-for-echo"


def test_compose_version():
assert "Docker Compose version v2" in docker.compose.version()

Expand Down

0 comments on commit 86804ee

Please sign in to comment.