Skip to content

Commit

Permalink
fix(core): add TESTCONTAINERS_HOST_OVERRIDE as alternative to TC_HOST (
Browse files Browse the repository at this point in the history
…#384)

Resolves #383 

This PR aims to unify the configuration for the Testcontainer
Hostvariable as it is in
[Java](https://java.testcontainers.org/features/configuration/#customizing-docker-host-detection)
and [Dotnet](https://dotnet.testcontainers.org/custom_configuration/)
(and potentially others).
  • Loading branch information
meiswjn committed Apr 17, 2024
1 parent e04b7ac commit 8073874
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
2 changes: 2 additions & 0 deletions core/testcontainers/core/docker_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,8 @@ def host(self) -> str:
# https://github.com/testcontainers/testcontainers-go/blob/dd76d1e39c654433a3d80429690d07abcec04424/docker.go#L644
# if os env TC_HOST is set, use it
host = os.environ.get("TC_HOST")
if not host:
host = os.environ.get("TESTCONTAINERS_HOST_OVERRIDE")
if host:
return host
try:
Expand Down
2 changes: 2 additions & 0 deletions index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ This snippet does the same, however using a specific version and the driver is s

Note, that the :code:`sqlalchemy` and :code:`psycopg` packages are no longer a dependency of :code:`testcontainers[postgres]` and not needed to launch the Postgres container. Your project therefore needs to declare a dependency on the used driver and db access methods you use in your code.

By default, Testcontainers will search for the container via the gateway IP. You can manually specify your own IP with the environment variable `TESTCONTAINERS_HOST_OVERRIDE`.


Installation
------------
Expand Down

0 comments on commit 8073874

Please sign in to comment.