Bug: Running `.exec` on `SqlServerContainer` instance hangs indefinitely
Describe the bug
I am trying to create a table within a SqlServer container during start up. I am running the necessary command via the exec method, but said method just hangs and never exits.
Additional info: When bashing into the container and running the command, it works just fine and the process does not hang. Furthermore, running a different SQL query via the exec method such as SELECT 1 works as well.
To Reproduce
with SqlServerContainer(image="mcr.microsoft.com/mssql/server:2022-CU12-ubuntu-22.04") as container:
container.exec(
"/opt/mssql-tools/bin/sqlcmd -U SA -P 1Secure*Password1 -d tempdb -Q 'CREATE TABLE test_table (id INT PRIMARY KEY)'"
)
Runtime environment
OS: Windows 11 Python version: 3.12.10 Docker version: 28.4.0, build d8eb465 Testcontainers version: 4.13.2
which statement hangs the creation/context or just the exec method call?
On Fri, Oct 24, 2025 at 3:03 PM Manos Stoumpos @.***> wrote:
manoss96 created an issue (testcontainers/testcontainers-python#910) https://github.com/testcontainers/testcontainers-python/issues/910
Describe the bug
I am trying to create a table within a SqlServer container during start up. I am running the necessary command via the exec method, but said method just hangs and never exits.
Additional info: When bashing into the container and running the command, it works just fine and the process does not hang. Furthermore, running a different SQL query via the exec method such as SELECT 1 works as well.
To Reproduce
with SqlServerContainer(image="mcr.microsoft.com/mssql/server:2022-CU12-ubuntu-22.04") as container: container.exec("/opt/mssql-tools/bin/sqlcmd -U SA -P 1Secure*Password1 -d tempdb -Q 'CREATE TABLE test_table (id INT PRIMARY KEY)'")
Runtime environment
OS: Windows 11 Python version: 3.12.10 Docker version: 28.4.0, build d8eb465 Testcontainers version: 4.13.2
— Reply to this email directly, view it on GitHub https://github.com/testcontainers/testcontainers-python/issues/910, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACECGJAZPBVUM6BBCVLRCC33ZJZZ3AVCNFSM6AAAAACKETSMCGVHI2DSMVQWIX3LMV43ASLTON2WKOZTGU2TANRVHAYDEMY . You are receiving this because you are subscribed to this thread.Message ID: @.***>
which statement hangs the creation/context or just the exec method call? …
The exec method call.