testcontainers/testcontainers-python

Bug: Docker environment variables are ignored in 4.2 and 4.3 when host is set

sku-0001 opened this issue ยท 5 comments

Describe the bug

Expected to be able to set the following environment variables:

DOCKER_HOST="https://docker:2376"
DOCKER_TLS_VERIFY=1
DOCKER_TLS_CERTDIR="/certs"
DOCKER_CERT_PATH="/certs/client"

After setting these, only DOCKER_HOST is read and applied, other TLS configuration is ignored.

To Reproduce

Try to set up a TLS based docker setup locally with the provided variables in the description.

Runtime environment

This was tested in gitlab kubernetes dind runner environment, but looking at the code this should not matter.
OS: Ubuntu 22.04 LTS
Python: 3.10.12
Testcontainers: 4.2 and 4.3 tested and failed, 4.1.2 works

Mostly related to the code here

@sku-0001 can you give https://pypi.org/project/testcontainers/4.3.1rc1/ a try? thanks!!!

actually that one also has a bug, but then it is doubly curious for me if it works for you - latest is on the branch:

pip install git+https://github.com/testcontainers/testcontainers-python.git@fix_no_more_from_env

Hello, thanks for the quick response.
I tried out the 4.3.1rc1 and got the following error:

.venv/lib/python3.10/site-packages/docker/client.py", line 99, in from_env
    **kwargs_from_env(**kwargs)
TypeError: kwargs_from_env() got an unexpected keyword argument 'base_url'

The base url could also be wrong in our internal django testcontainers runner library so take this with a grain of salt ๐Ÿ˜„

Also tried the fix_no_more_from_env branch and it works without any modifications ๐Ÿ‘

Hopefully this helps.

thanks for the quick feedback. going to release the fix for the branch shortly and yank the rc. i always seem to miss the mark with those ๐Ÿ™ƒ

@sku-0001 sorry i got distracted earlier - 4.3.1 is out now, containing the fix you tested on the branch.