testcontainers / testcontainers/testcontainers-python

Bug: Running `.exec` on `SqlServerContainer` instance hangs indefinitely

Open
#910 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
2.3k
Forks
386
Avg merge
4h 40m
Merged PRs (30d)
1

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the SqlServerContainer exec entry point and reproduce the exact sqlcmd CREATE TABLE command from the issue, comparing it with the working SELECT 1 example. Done means the CREATE TABLE command exits normally through exec, as it does when run inside the container.

Written by the indexing model from the issue text.

Assessment

Tech stack
docker, python, sql
Domain
databases, devops
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.