mirror of
https://github.com/jupyter/docker-stacks.git
synced 2025-10-18 15:32:56 +00:00
Use tty for running docker commands by default (#2260)
* Use tty for running docker commands by default * Add comment about using tty=False * Remove unrelated part
This commit is contained in:
@@ -175,11 +175,10 @@ def test_set_uid(container: TrackedContainer) -> None:
|
||||
Additionally, verify that "--group-add=users" is suggested in a warning to restore
|
||||
write access.
|
||||
"""
|
||||
# This test needs to have tty disabled, the reason is explained here:
|
||||
# https://github.com/jupyter/docker-stacks/pull/2260#discussion_r2008821257
|
||||
logs = container.run_and_wait(
|
||||
timeout=5,
|
||||
no_warnings=False,
|
||||
user="1010",
|
||||
command=["id"],
|
||||
timeout=5, no_warnings=False, user="1010", command=["id"], tty=False
|
||||
)
|
||||
assert "uid=1010(jovyan) gid=0(root)" in logs
|
||||
warnings = TrackedContainer.get_warnings(logs)
|
||||
|
@@ -45,8 +45,10 @@ class TrackedContainer:
|
||||
extending and/or overriding key/value pairs passed to the constructor
|
||||
"""
|
||||
LOGGER.info(f"Running {self.image_name} with args {kwargs} ...")
|
||||
default_kwargs = {"detach": True, "tty": True}
|
||||
final_kwargs = default_kwargs | kwargs
|
||||
self.container = self.docker_client.containers.run(
|
||||
self.image_name, **kwargs, detach=True
|
||||
self.image_name, **final_kwargs
|
||||
)
|
||||
|
||||
def get_logs(self) -> str:
|
||||
@@ -64,7 +66,9 @@ class TrackedContainer:
|
||||
assert self.container is not None
|
||||
container = self.container
|
||||
LOGGER.info(f"Running cmd: `{cmd}` on container: {container.name}")
|
||||
exec_result = container.exec_run(cmd, **kwargs)
|
||||
default_kwargs = {"tty": True}
|
||||
final_kwargs = default_kwargs | kwargs
|
||||
exec_result = container.exec_run(cmd, **final_kwargs)
|
||||
output = exec_result.output.decode().rstrip()
|
||||
assert isinstance(output, str)
|
||||
LOGGER.info(f"Command output: {output}")
|
||||
|
Reference in New Issue
Block a user