Skip to content

[Bug]: Testcontainers.MsSql 4.5.0 breaks compatibility with Podman #1463

Description

@ViktorWorkAccount

Testcontainers version

4.5.0

Using the latest Testcontainers version?

Yes

Host OS

Windows (Windows Subsystem for Linux)

Host arch

x64

.NET version

net8.0

Docker version

Podman v5.5.1

Docker info

Client:
  APIVersion: 5.5.1
  Built: 1749160159
  BuiltTime: Thu Jun  5 23:49:19 2025
  GitCommit: 850db76dd78a0641eddb9ee19ee6f60d2c59bcfa
  GoVersion: go1.24.3
  Os: windows
  OsArch: windows/amd64
  Version: 5.5.1
host:
  arch: amd64
  buildahVersion: 1.35.4
  cgroupControllers:
  - cpuset
  - cpu
  - io
  - memory
  - hugetlb
  - pids
  - rdma
  cgroupManager: cgroupfs
  cgroupVersion: v2
  conmon:
    package: conmon-2.1.10-1.fc40.x86_64
    path: /usr/bin/conmon
    version: 'conmon version 2.1.10, commit: '
  cpuUtilization:
    idlePercent: 99.56
    systemPercent: 0.22
    userPercent: 0.22
  cpus: 10
  databaseBackend: sqlite
  distribution:
    distribution: fedora
    variant: container
    version: "40"
  eventLogger: journald
  freeLocks: 2018
  hostname: ViktorR02
  idMappings:
    gidmap: null
    uidmap: null
  kernel: 6.6.87.1-microsoft-standard-WSL2
  linkmode: dynamic
  logDriver: journald
  memFree: 7498211328
  memTotal: 8128274432
  networkBackend: netavark
  networkBackendInfo:
    backend: netavark
    dns:
      package: aardvark-dns-1.10.0-1.fc40.x86_64
      path: /usr/libexec/podman/aardvark-dns
      version: aardvark-dns 1.10.0
    package: netavark-1.10.3-3.fc40.x86_64
    path: /usr/libexec/podman/netavark
    version: netavark 1.10.3
  ociRuntime:
    name: crun
    package: crun-1.15-1.fc40.x86_64
    path: /usr/bin/crun
    version: |-
      crun version 1.15
      commit: e6eacaf4034e84185fd8780ac9262bbf57082278
      rundir: /run/crun
      spec: 1.0.0
      +SYSTEMD +SELINUX +APPARMOR +CAP +SECCOMP +EBPF +CRIU +LIBKRUN +WASM:wasmedge +YAJL
  os: linux
  pasta:
    executable: /usr/bin/pasta
    package: passt-0^20240510.g7288448-1.fc40.x86_64
    version: |
      pasta 0^20240510.g7288448-1.fc40.x86_64
      Copyright Red Hat
      GNU General Public License, version 2 or later
        <https://www.gnu.org/licenses/old-licenses/gpl-2.0.html>
      This is free software: you are free to change and redistribute it.
      There is NO WARRANTY, to the extent permitted by law.
  remoteSocket:
    exists: true
    path: /run/podman/podman.sock
  rootlessNetworkCmd: ""
  security:
    apparmorEnabled: false
    capabilities: CAP_CHOWN,CAP_DAC_OVERRIDE,CAP_FOWNER,CAP_FSETID,CAP_KILL,CAP_NET_BIND_SERVICE,CAP_SETFCAP,CAP_SETGID,CAP_SETPCAP,CAP_SETUID,CAP_SYS_CHROOT
    rootless: false
    seccompEnabled: true
    seccompProfilePath: /usr/share/containers/seccomp.json
    selinuxEnabled: false
  serviceIsRemote: true
  slirp4netns:
    executable: ""
    package: ""
    version: ""
  swapFree: 2147483648
  swapTotal: 2147483648
  uptime: 0h 21m 13.00s
  variant: ""
plugins:
  authorization: null
  log:
  - k8s-file
  - none
  - passthrough
  - journald
  network:
  - bridge
  - macvlan
  - ipvlan
  volume:
  - local
registries:
  search:
  - docker.io
store:
  configFile: /usr/share/containers/storage.conf
  containerStore:
    number: 8
    paused: 0
    running: 0
    stopped: 8
  graphDriverName: overlay
  graphOptions:
    overlay.imagestore: /usr/lib/containers/storage
    overlay.mountopt: nodev,metacopy=on
  graphRoot: /var/lib/containers/storage
  graphRootAllocated: 1081101176832
  graphRootUsed: 29871857664
  graphStatus:
    Backing Filesystem: extfs
    Native Overlay Diff: "false"
    Supports d_type: "true"
    Supports shifting: "true"
    Supports volatile: "true"
    Using metacopy: "true"
  imageCopyTmpDir: /var/tmp
  imageStore:
    number: 38
  runRoot: /run/containers/storage
  transientStore: false
  volumePath: /var/lib/containers/storage/volumes
version:
  APIVersion: 5.0.3
  Built: 1715299200
  BuiltTime: Fri May 10 02:00:00 2024
  GitCommit: ""
  GoVersion: go1.22.2
  Os: linux
  OsArch: linux/amd64
  Version: 5.0.3

What happened?

After upgrading Testcontainers.MsSql from version 4.4.0 to 4.5.0, our integration tests fail when using Podman as the container runtime. The error encountered is:
System.InvalidOperationException: cannot hijack chunked or content length stream
This issue does not occur with version 4.4.0, indicating a regression introduced in the latest release.

Steps to Reproduce:
Set up integration tests using Testcontainers.MsSql 4.5.0.
Run the tests with Podman as the container runtime.
Observe the failure with the specified error message.

Relevant log output

Message: 
System.InvalidOperationException : cannot hijack chunked or content length stream

  Stack Trace: 
HttpConnectionResponseContent.HijackStream()
DockerClient.MakeRequestForHijackedStreamAsync(IEnumerable`1 errorHandlers, HttpMethod method, String path, IQueryString queryString, IRequestContent body, IDictionary`2 headers, TimeSpan timeout, CancellationToken cancellationToken)
ExecOperations.StartContainerExecAsync(String id, ContainerExecStartParameters parameters, CancellationToken cancellationToken)
DockerContainerOperations.ExecAsync(String id, IList`1 command, CancellationToken ct)
MsSqlContainer.FindSqlCmdFilePathAsync()
WaitUntil.UntilAsync(MsSqlContainer container)
DockerContainer.CheckReadinessAsync(WaitStrategy waitStrategy, CancellationToken ct)
<<WaitUntilAsync>g__UntilAsync|0>d.MoveNext()
--- End of stack trace from previous location ---
WaitStrategy.WaitUntilAsync(Func`1 wait, TimeSpan interval, TimeSpan timeout, Int32 retries, CancellationToken ct)
DockerContainer.CheckReadinessAsync(IEnumerable`1 waitStrategies, CancellationToken ct)
DockerContainer.UnsafeStartAsync(CancellationToken ct)
DockerContainer.StartAsync(CancellationToken ct)

Additional information

C# code as we use it:
private readonly MsSqlContainer _msSqlContainer;
_msSqlContainer = new MsSqlBuilder().Build();
services.AddDbContext((serviceProvider, options) =>
{
options.UseSqlServer(_msSqlContainer.GetConnectionString(), .... );
});
await _msSqlContainer.StartAsync();

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions