Skip to content

Commit

Permalink
Add tty and interactive flags to container create and start (#545)
Browse files Browse the repository at this point in the history
  • Loading branch information
LewisGaul authored Feb 1, 2024
1 parent f9d129b commit d8420f9
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions python_on_whales/components/container/cli_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -387,14 +387,14 @@ def remove(self, force: bool = False, volumes: bool = False) -> None:
)

def start(
self, attach: bool = False, stream: bool = False
self, attach: bool = False, interactive: bool = False, stream: bool = False
) -> Union[None, str, Iterable[Tuple[str, bytes]]]:
"""Starts this container.
See the [`docker.container.start`](../sub-commands/container.md#start) command for
information about the arguments.
"""
return ContainerCLI(self.client_config).start(self, attach, stream)
return ContainerCLI(self.client_config).start(self, attach, interactive, stream)

def stop(self, time: Union[int, timedelta] = None) -> None:
"""Stops this container.
Expand Down Expand Up @@ -571,6 +571,7 @@ def create(
health_timeout: Union[None, int, timedelta] = None,
hostname: Optional[str] = None,
init: bool = False,
interactive: bool = False,
ip: Optional[str] = None,
ip6: Optional[str] = None,
ipc: Optional[str] = None,
Expand Down Expand Up @@ -615,6 +616,7 @@ def create(
sysctl: Dict[str, str] = {},
systemd: Optional[Union[bool, Literal["always"]]] = None,
tmpfs: List[ValidPath] = [],
tty: bool = False,
ulimit: List[str] = [],
user: Optional[str] = None,
userns: Optional[str] = None,
Expand Down Expand Up @@ -714,6 +716,7 @@ def create(
full_cmd.add_simple_arg("--hostname", hostname)

full_cmd.add_flag("--init", init)
full_cmd.add_flag("--interactive", interactive)

full_cmd.add_simple_arg("--ip", ip)
full_cmd.add_simple_arg("--ip6", ip6)
Expand Down Expand Up @@ -777,6 +780,7 @@ def create(
full_cmd.add_args_list("--sysctl", format_dict_for_cli(sysctl))
full_cmd.add_simple_arg("--systemd", systemd)
full_cmd.add_args_list("--tmpfs", tmpfs)
full_cmd.add_flag("--tty", tty)
full_cmd.add_args_list("--ulimit", ulimit)

full_cmd.add_simple_arg("--user", user)
Expand Down Expand Up @@ -1590,7 +1594,6 @@ def run(
full_cmd.add_flag("--init", init)

full_cmd.add_flag("--interactive", interactive)
full_cmd.add_flag("--tty", tty)

full_cmd.add_simple_arg("--ip", ip)
full_cmd.add_simple_arg("--ip6", ip6)
Expand Down Expand Up @@ -1655,6 +1658,7 @@ def run(
full_cmd.add_args_list("--sysctl", format_dict_for_cli(sysctl))
full_cmd.add_simple_arg("--systemd", systemd)
full_cmd.add_args_list("--tmpfs", tmpfs)
full_cmd.add_flag("--tty", tty)
full_cmd.add_args_list("--ulimit", ulimit)

full_cmd.add_simple_arg("--user", user)
Expand Down Expand Up @@ -1689,15 +1693,19 @@ def start(
self,
containers: Union[ValidContainer, List[ValidContainer]],
attach: bool = False,
interactive: bool = False,
stream: bool = False,
) -> Union[None, str, Iterable[Tuple[str, bytes]]]:
"""Starts one or more stopped containers.
"""Starts one or more created/stopped containers.
Aliases: `docker.start`, `docker.container.start`,
`python_on_whales.Container.start`.
Parameters:
containers: One or a list of containers.
attach: Attach stdout/stderr and forward signals.
interactive: Attach stdin (ensure it is open).
stream: Stream output as a generator.
"""
containers = to_list(containers)
if containers == []:
Expand All @@ -1712,6 +1720,7 @@ def start(
)
full_cmd = self.docker_cmd + ["container", "start"]
full_cmd.add_flag("--attach", attach)
full_cmd.add_flag("--interactive", interactive)
full_cmd += containers

if stream:
Expand Down

0 comments on commit d8420f9

Please sign in to comment.