Fix docker.run_command() needing detach but not enforcing it (#5979)

* Fix `docker.run_command()` needing `detach` but not enforcing it

* Fix test
This commit is contained in:
Felipe Santos 2025-06-30 11:09:19 -03:00 committed by GitHub
parent cf32f036c0
commit d1c1a2d418
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 4 additions and 4 deletions

View File

@ -213,9 +213,6 @@ class DockerHomeAssistant(DockerInterface):
privileged=True, privileged=True,
init=True, init=True,
entrypoint=[], entrypoint=[],
detach=True,
stdout=True,
stderr=True,
mounts=[ mounts=[
Mount( Mount(
type=MountType.BIND.value, type=MountType.BIND.value,

View File

@ -313,6 +313,7 @@ class DockerAPI:
container = self.docker.containers.run( container = self.docker.containers.run(
image_with_tag, image_with_tag,
command=command, command=command,
detach=True,
network=self.network.name, network=self.network.name,
use_config_proxy=False, use_config_proxy=False,
**kwargs, **kwargs,
@ -331,7 +332,7 @@ class DockerAPI:
with suppress(docker_errors.DockerException, requests.RequestException): with suppress(docker_errors.DockerException, requests.RequestException):
container.remove(force=True, v=True) container.remove(force=True, v=True)
return CommandReturn(result.get("StatusCode"), output) return CommandReturn(result["StatusCode"], output)
def repair(self) -> None: def repair(self) -> None:
"""Repair local docker overlayfs2 issues.""" """Repair local docker overlayfs2 issues."""

View File

@ -34,6 +34,7 @@ async def test_run_command_success(docker: DockerAPI):
docker.docker.containers.run.assert_called_once_with( docker.docker.containers.run.assert_called_once_with(
"alpine:3.18", "alpine:3.18",
command="echo hello", command="echo hello",
detach=True,
network=docker.network.name, network=docker.network.name,
use_config_proxy=False, use_config_proxy=False,
stdout=True, stdout=True,
@ -66,6 +67,7 @@ async def test_run_command_with_defaults(docker: DockerAPI):
docker.docker.containers.run.assert_called_once_with( docker.docker.containers.run.assert_called_once_with(
"ubuntu:latest", # default tag "ubuntu:latest", # default tag
command=None, # default command command=None, # default command
detach=True,
network=docker.network.name, network=docker.network.name,
use_config_proxy=False, use_config_proxy=False,
) )