Skip to content

Bug: Running .exec on SqlServerContainer instance hangs indefinitely #910

@manoss96

Description

@manoss96

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

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