-
Notifications
You must be signed in to change notification settings - Fork 298
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
Containers fail to start: mssql/win11, mssql/m1, mssql with different port (not intended to work), postgres/win10, mariadb/win11, oracle #360
Comments
Does it finish execution at some point? Because your code does not actually print anything so you would see no output even if it works... from sqlalchemy import create_engine, text
from testcontainers.mssql import SqlServerContainer
with SqlServerContainer() as mssql:
engine = create_engine(mssql.get_connection_url())
with engine.begin() as connection:
version = connection.execute(text("select @@VERSION"))
print(version.all()) This works fine for me (on linux though): $ python baz.py
Pulling image mcr.microsoft.com/mssql/server:2019-latest
Container started: 813db1176b94
Waiting to be ready...
Waiting to be ready...
Waiting to be ready...
Waiting to be ready...
Waiting to be ready...
Waiting to be ready...
Waiting to be ready...
Waiting to be ready...
Waiting to be ready...
mssql+pymssql://SA:1Secure*Password1@localhost:49158/tempdb
[('Microsoft SQL Server 2019 (RTM-CU21) (KB5025808) - 15.0.4316.3 (X64) \n\tJun 1 2023 16:32:31 \n\tCopyright (C) 2019 Microsoft Corporation\n\tDeveloper Edition (64-bit) on Linux (Ubuntu 20.04.6 LTS) <X64>',)] |
Any updates on this? I am facing the same issue on mac m1 machine. |
Hello, Any news ? Same for me here ! EDIT : It works if I do not change the default port for me |
Same for me but for the PostgreSQL container:
Code is: from testcontainers.postgres import PostgresContainer
postgres_container = PostgresContainer("postgres:latest", port=54321, dbname=database_name)
with postgres_container as postgres:
# Get the connection details for the container
connection_details = postgres.get_connection_url() env:
|
There is a temporary solution mentioned for this issue: |
I've encountered this same issue with import subprocess
from testcontainers.core.container import DockerContainer
from testcontainers.core.waiting_utils import wait_for_logs
from time import sleep
from tqdm import tqdm
IMAGE="mariadb:11.1.2"
# Run the docker pull as a separate process since relying on testcontainers to
# pull through the API on windows gives me some issue.
if subprocess.run(["docker", "pull", IMAGE]).returncode == 1:
raise Exception(
f"Unable to pull image '{IMAGE}'. Make sure the Docker daemon is "
"running. If problems persist, you can pull the image manually."
)
container = DockerContainer(image=IMAGE)
container.env={
"MARIADB_ALLOW_EMPTY_ROOT_PASSWORD": "1",
"MARIADB_ALLOW_EMPTY_PASSWORD": "1",
}
container.start()
waiting = wait_for_logs(container, "ready for connections")
print(container.get_container_host_ip)
for i in tqdm(range(20)):
# Take this time to check docker that the container is running!
sleep(1)
container.stop() I hope this helps someone! |
Same for me for Oracle
env
|
<Quoted Reply>
Thanks to @nsaccente reply. I managed to make something that works for Oracle on Windows 10. I hope this helps someone. oracle container sample code
|
@thuyng-ing i think this is the module we are looking to merge for oracle but i guess we will be looking at these suggestions as well when we are able to publish again - #363 |
<Quoted Reply>
@pytest.fixture(scope="session", autouse=True)
def setup_testdb():
image = "mcr.microsoft.com/mssql/server:2022-latest"
container = DockerContainer(image=image)
container.env = {
"ACCEPT_EULA": "Y",
"MSSQL_SA_PASSWORD":"1TestTest!"
}
container.with_bind_ports(1433, host=1433)
with container as mssql:
wait_for_logs(container, "SQL Server is now ready for client connections")
print(mssql.get_container_host_ip())
yield mssql The above listing adapted for usage within a pytest.fixture and mssql. Thank you very much for your help! |
I have the same problem Just wanted to add a clue to the problem solving (I know below isn't really practical as a solution)... If I debug into the In fact, adding a sleep to the start method of the |
The SQL Server images take a looong time to start in most cases. To try pinpointing the errors here further, you could try the following:
Also note that the default
Lastly, to check that you are able to start the image at all, try starting it manually with
|
On another note: If #525 lands, the wait strategy will change and testing will be more robust for more image versions which might fix your problems. |
I'm unable to run the SqlServerContainer. After creating the MSSQL container, it gets stuck at the "waiting to be ready" state and does not proceed further.
To Reproduce
Runtime environment
The text was updated successfully, but these errors were encountered: