8000 fix: no connect to docker on startup by alexanderankin · Pull Request #831 · testcontainers/testcontainers-python · GitHub
[go: up one dir, main page]

Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions core/testcontainers/core/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def get_docker_socket() -> str:
RYUK_IMAGE: str = environ.get("RYUK_CONTAINER_IMAGE", "testcontainers/ryuk:0.8.1")
RYUK_PRIVILEGED: bool = environ.get("TESTCONTAINERS_RYUK_PRIVILEGED", "false") == "true"
RYUK_DISABLED: bool = environ.get("TESTCONTAINERS_RYUK_DISABLED", "false") == "true"
RYUK_DOCKER_SOCKET: str = get_docker_socket()
RYUK_DOCKER_SOCKET: str = "" # get_docker_socket()
RYUK_RECONNECTION_TIMEOUT: str = environ.get("RYUK_RECONNECTION_TIMEOUT", "10s")
TC_HOST_OVERRIDE: Optional[str] = environ.get("TC_HOST", environ.get("TESTCONTAINERS_HOST_OVERRIDE"))

Expand Down Expand Up @@ -99,7 +99,7 @@ class TestcontainersConfiguration:
ryuk_image: str = RYUK_IMAGE
ryuk_privileged: bool = RYUK_PRIVILEGED
ryuk_disabled: bool = RYUK_DISABLED
ryuk_docker_socket: str = RYUK_DOCKER_SOCKET
# ryuk_docker_socket: str = RYUK_DOCKER_SOCKET
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# ryuk_docker_socket: str = RYUK_DOCKER_SOCKET
_ryuk_docker_socket: str = ""

ryuk_reconnection_timeout: str = RYUK_RECONNECTION_TIMEOUT
tc_properties: dict[str, str] = field(default_factory=read_tc_properties)
_docker_auth_config: Optional[str] = field(default_factory=lambda: environ.get("DOCKER_AUTH_CONFIG"))
Expand Down Expand Up @@ -131,6 +131,10 @@ def tc_properties_get_tc_host(self) -> Union[str, None]:
def timeout(self) -> int:
return self.max_tries * self.sleep_time

@property
def ryuk_docker_socket(self) -> str:
return get_docker_socket()
Comment on lines +134 to +136
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
@property
def ryuk_docker_socket(self) -> str:
return get_docker_socket()
@property
def ryuk_docker_socket(self) -> str:
if not self._ryuk_docker_socket:
self.ryuk_docker_socket = get_docker_socket()
return self._ryuk_docker_socket
@ryuk_docker_socket.setter
def ryuk_docker_socket(self, value: str) -> None:
self._ryuk_docker_socket = value

Cache the result but make it changeable



testcontainers_config = TestcontainersConfiguration()

Expand Down
0