testcontainers / testcontainers-dotnet

A library to support tests with throwaway instances of Docker containers for all compatible .NET Standard versions.
https://dotnet.testcontainers.org
MIT License
3.82k stars 278 forks source link

[Bug]: MSSQL containers is not running on Ubuntu latest version #1274

Closed ariam-vestas closed 1 month ago

ariam-vestas commented 1 month ago

Testcontainers version

3.10.0

Using the latest Testcontainers version?

Yes

Host OS

Linux

Host arch

x86

.NET version

.Net 8.0

Docker version

Docker Compose v2 2.27.1
Docker-Buildx 0.17.1
Docker Client 26.1.3
Docker Server 26.1.3

Docker info

docker info
  shell: /usr/bin/bash -e {0}
  env:
    DOTNET_ROOT: /usr/share/dotnet
Client: Docker Engine - Community
 Version:    26.1.3
 Context:    default
 Debug Mode: false
 Plugins:
  buildx: Docker Buildx (Docker Inc.)
    Version:  v0.17.1
    Path:     /usr/libexec/docker/cli-plugins/docker-buildx
  compose: Docker Compose (Docker Inc.)
    Version:  v2.27.1
    Path:     /usr/libexec/docker/cli-plugins/docker-compose

Server:
 Containers: 0
  Running: 0
  Paused: 0
  Stopped: 0
 Images: 15
 Server Version: 26.1.3
 Storage Driver: overlay2
  Backing Filesystem: extfs
  Supports d_type: true
  Using metacopy: false
  Native Overlay Diff: false
  userxattr: false
 Logging Driver: json-file
 Cgroup Driver: cgroupfs
 Cgroup Version: 2
 Plugins:
  Volume: local
  Network: bridge host ipvlan macvlan null overlay
  Log: awslogs fluentd gcplogs gelf journald json-file local splunk syslog
 Swarm: inactive
 Runtimes: io.containerd.runc.v2 runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: 7f7fdf5fed64eb6a7caf99b3e12efcf9d60e311c
 runc version: v1.1.14-0-g2c9f560
 init version: de40ad0
 Security Options:
  apparmor
  seccomp
   Profile: builtin
  cgroupns
 Kernel Version: 6.8.0-1014-azure
 Operating System: Ubuntu 22.04.5 LTS
 OSType: linux
 Architecture: x86_64
 CPUs: 2
 Total Memory: 7.753GiB
 Name: fv-az1758-575
 ID: 2585078c-9c7d-4e3d-9a4a-1d665b16792a
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 Username: githubactions
 Experimental: false
 Insecure Registries:
  127.0.0.0/8
 Live Restore Enabled: false

What happened?

MsSqlContainer has started failing when running on Ubuntu LTS version (Image: ubuntu-22.04, Version: 20240922.1.0) Before, I was running without any issues.

Relevant log output

Error Message:
   Docker.DotNet.DockerApiException : Docker API responded with status code=Conflict, response={"message":"container b362ae415d6bb64f9b31ebd9d07ce80273ed91b6831a0f0e4fcbc438ba37960a is not running"}

  Stack Trace:
     at Docker.DotNet.DockerClient.HandleIfErrorResponseAsync(HttpStatusCode statusCode, HttpResponseMessage response, IEnumerable`1 handlers)
   at Docker.DotNet.DockerClient.MakeRequestAsync(IEnumerable`1 errorHandlers, HttpMethod method, String path, IQueryString queryString, IRequestContent body, IDictionary`2 headers, TimeSpan timeout, CancellationToken token)
   at Docker.DotNet.ExecOperations.ExecCreateContainerAsync(String id, ContainerExecCreateParameters parameters, CancellationToken cancellationToken)
   at DotNet.Testcontainers.Clients.DockerContainerOperations.ExecAsync(String id, IList`1 command, CancellationToken ct)
   at Testcontainers.MsSql.MsSqlBuilder.WaitUntil.UntilAsync(IContainer container)
   at DotNet.Testcontainers.Containers.DockerContainer.<>c__DisplayClass60_0.<<UnsafeStartAsync>g__CheckWaitStrategyAsync|1>d.MoveNext()
--- End of stack trace from previous location ---
   at DotNet.Testcontainers.Configurations.WaitStrategy.<>c__DisplayClass1_0.<<WaitUntilAsync>g__UntilAsync|0>d.MoveNext()

Additional information

It fails when I call the MsSqlBuilder StartAsync() method. I have seen some closed issues with the same problem. It seems to be a regression in the VM image for gitHub hosted runners. I actually saw some workarounds that could be implemented by our own hand, such as specifically getting the image after starting MsSqlBuilder like

WithImage("mcr.microsoft.com/mssql/server:2022-CU14-ubuntu-22.04").

or change the runner on the github pipeline to use an older Ubuntu version.

On my pipelines I usually use runs-on: ubuntu-latest and I don't see any advantage in changing the pipeline or the code just to fix a problem that is not mine. Would you please, revisit again this issue and try deploying a new nuget version with a bug fix? If the issue persists, we will be forced to try find another approach like use other nuget.

HofmeisterAn commented 1 month ago

Hi 👋 this issue has already been addressed. Please see: https://github.com/testcontainers/testcontainers-dotnet/pull/1265.

ariam-vestas commented 1 month ago

Hi 👋 this issue has already been addressed. Please see: #1265.

Any idea when a new release with this fix will be released?

HofmeisterAn commented 1 month ago

No ETA. You can simply pin and override the image as mentioned in the PR as a workaround (which we recommend doing anyway).