Skip to content

Bug: Connection mode override environment variable is not honored #774

Closed
@mschmitzer

Description

@mschmitzer

Describe the bug

The testcontainers.core.config module defines a get_user_overridden_connection_mode function that reads the TESTCONTAINERS_CONNECTION_MODE environment variable. This looks as though it should be used to initialize the connection_mode_override member of the testcontainers_config object, but is actually unused.

I guess this might be intentional, but it would seem useful to be able to easily control the connection mode from the environment.

To Reproduce

import os
os.environ["TESTCONTAINERS_CONNECTION_MODE"] = "bridge_ip"
import testcontainers.core.config as config
assert config.testcontainers_config.connection_mode_override == config.ConnectionMode.bridge_ip

Runtime environment

$ uname -a
Linux *** 6.8.0-52-generic #53-Ubuntu SMP PREEMPT_DYNAMIC Sat Jan 11 00:06:25 UTC 2025 x86_64 x86_64 x86_64 GNU/Linux
$ python --version
Python 3.9.2
$ pip freeze
certifi==2025.1.31
charset-normalizer==3.4.1
docker==7.1.0
idna==3.10
python-dotenv==1.0.1
requests==2.32.3
testcontainers==4.9.1
typing_extensions==4.12.2
urllib3==2.3.0
wrapt==1.17.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions