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

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

Nobody has claimed this yet.

Assessment

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

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.

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

Dominant language
Python
Stars
2.3k
Forks
397
Avg merge
8d 16h
Merged PRs (30d)
5

Getting set up

Open in Codespaces

Starts the project's dev container in your browser, under your own GitHub account.

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.

More from testcontainers/testcontainers-python

All issues in testcontainers/testcontainers-python

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.