-
Notifications
You must be signed in to change notification settings - Fork 300
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
'DockerContainer' object has no attribute '_container' #399
Comments
im trying and failing to reproduce (on ubuntu) with: uname -a # Linux z14-1 6.2.0-36-generic #37~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Mon Oct 9 15:34:04 UTC 2 x86_64 x86_64 x86_64 GNU/Linux
python -V # Python 3.9.18
mkdir testcontainers-python-issues-399 && cd $_
python -m venv .venv && . .venv/bin/activate
cat > test.py <<EOF
from testcontainers.postgres import PostgresContainer
def get_postgres_uri():
# Use a PostgreSQL Docker container for testing
with PostgresContainer("postgres:16-alpine") as postgres:
return postgres.get_connection_url()
print(get_postgres_uri())
EOF
python test.py and i get these logs: $ python test.py
Pulling image postgres:16-alpine
Container started: 84479badddc7
Waiting to be ready...
Waiting to be ready...
Waiting to be ready...
Waiting to be ready...
Waiting to be ready...
postgresql+psycopg2://test:test@localhost:32769/test docker version is also 24: $ docker -v
Docker version 24.0.7, build afdd53b i dont think this means there isn't an issue - maybe spending some time staring at the code of the library will show some obvious codepaths which cause the issue |
This happened for me as well on OSX. As I am using Rancher I attributed it to the unsupported runtime, but could be wrong of course. |
Same issue! |
heyo, I think this isn't OS dependent, but makes for some flaky testing So I think this is defo a bug related to failing to create the container |
In fact I'm getting more convinced this issue is present when we encounter issues with the docker client. Some refactoring and defensive coding is needed as it seems. |
# change Fixes #399. Applied a bit of defensive coding and attempted to create some tests for it, however reproducing it with a local dev machine is not easy. I did my best to reproduce the issue with garbage collection in the new test. --------- Co-authored-by: Balint Bartha <[email protected]>
Creating Postgres Container instance results in error: 'PostgresContainer' object has no attribute '_container'
I tried starting a Postgres container and got the following error:
I already saw an issue #353 which was about the same error but it seems to persist.
See the code I used below.
To Reproduce
I also tried out the code in the postgres/tests/test_postgres.py file and it failed with the same error message.
Runtime environment
OS: Pop!_OS 22.04 LTS x86_64
Python version: Python 3.9.12
Docker version: 24.0.5
testcontainers version: 3.7.1
The text was updated successfully, but these errors were encountered: