Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: MSSQL containers is not running on Ubuntu 22.04.5 #1264

Closed
JoseDevUFC opened this issue Sep 19, 2024 · 4 comments
Closed

[Bug]: MSSQL containers is not running on Ubuntu 22.04.5 #1264

JoseDevUFC opened this issue Sep 19, 2024 · 4 comments
Labels
bug Something isn't working

Comments

@JoseDevUFC
Copy link

Testcontainers version

3.10.0

Using the latest Testcontainers version?

Yes

Host OS

Ubuntu 22.04 OS Version: 22.04.5 LTS Kernel Version: 6.8.0-1014-azure Image Version: 20240915.1.0 Systemd version: 249.11-0ubuntu3.12

Host arch

x86

.NET version

8.0.401

Docker version

Docker Amazon ECR Credential Helper 0.8.0
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 22.04.5 LTS before I was running on Ubuntu 22.04.4 LTS without any issues.

Relevant log output

System.InvalidOperationException : Could not find resource 'MsSqlContainer'. Please create the resource by calling StartAsync(CancellationToken) or CreateAsync(CancellationToken).
TearDown : System.NullReferenceException : Object reference not set to an instance of an object.
StackTrace:    at DotNet.Testcontainers.Guard.ThrowIf[TType](ArgumentInfo`1& argument, Func`2 condition, Func`2 ifClause) in /_/src/Testcontainers/Guard.Null.cs:line 62
   at DotNet.Testcontainers.Resource.ThrowIfResourceNotFound() in /_/src/Testcontainers/Resource.cs:line 79
   at DotNet.Testcontainers.Containers.DockerContainer.get_Id() in /_/src/Testcontainers/Containers/DockerContainer.cs:line 82
   at DotNet.Testcontainers.Containers.DockerContainer.ExecAsync(IList`1 command, CancellationToken ct) in /_/src/Testcontainers/Containers/DockerContainer.cs:line 338
   at Testcontainers.MsSql.MsSqlBuilder.WaitUntil.UntilAsync(MsSqlContainer container) in /_/src/Testcontainers.MsSql/MsSqlBuilder.cs:line 146
   at DotNet.Testcontainers.Containers.DockerContainer.CheckReadinessAsync(WaitStrategy waitStrategy, CancellationToken ct) in /_/src/Testcontainers/Containers/DockerContainer.cs:line 534
   at DotNet.Testcontainers.Configurations.WaitStrategy.<>c__DisplayClass24_0.<<WaitUntilAsync>g__UntilAsync|0>d.MoveNext() in /_/src/Testcontainers/Configurations/WaitStrategies/WaitStrategy.cs:line 184
--- End of stack trace from previous location ---
   at DotNet.Testcontainers.Configurations.WaitStrategy.WaitUntilAsync(Func`1 wait, TimeSpan interval, TimeSpan timeout, Int32 retries, CancellationToken ct) in /_/src/Testcontainers/Configurations/WaitStrategies/WaitStrategy.cs:line 213
   at DotNet.Testcontainers.Containers.DockerContainer.CheckReadinessAsync(IEnumerable`1 waitStrategies, CancellationToken ct) in /_/src/Testcontainers/Containers/DockerContainer.cs:line 552
   at DotNet.Testcontainers.Containers.DockerContainer.UnsafeStartAsync(CancellationToken ct) in /_/src/Testcontainers/Containers/DockerContainer.cs:line 479
   at DotNet.Testcontainers.Containers.DockerContainer.StartAsync(CancellationToken ct) in /_/src/Testcontainers/Containers/DockerContainer.cs:line 282

Additional information

It fails when I call the MsSqlBuilder StartAsync() method:

` public TestcontainersTestDatabase()
{
_container = new MsSqlBuilder()
.WithAutoRemove(true)
.Build();
}

    public async Task InitialiseAsync()
    {
        await _container.StartAsync();

        _connectionString = _container.GetConnectionString();

        _connection = new SqlConnection(_connectionString);

        var options = new DbContextOptionsBuilder<ApplicationDbContext>()
            .UseSqlServer(_connectionString)
            .Options;

        var context = new ApplicationDbContext(options);

        context.Database.Migrate();

        _respawner = await Respawner.CreateAsync(_connectionString, new RespawnerOptions
        {
            TablesToIgnore = new Respawn.Graph.Table[] { "__EFMigrationsHistory" }
        });
    }`
@JoseDevUFC JoseDevUFC added the bug Something isn't working label Sep 19, 2024
@HofmeisterAn
Copy link
Collaborator

This is a regression in the recent VM image update (Ubuntu-22.04) for GitHub-hosted runners and Microsoft-hosted agents: actions/runner-images#10649. I am working on a PR right now - sorry for the inconvenience - MS 🤷. Please update the image to:

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

@kakins
Copy link

kakins commented Sep 24, 2024

Is this still an issue? I've been seeing problems since I noticed Ubuntu 22.04.5 running in azure pipelines with testcontainers. 22.04.4 was/is working fine.

Seems like it is having trouble starting/verifying sql server

  Host: unix:///var/run/docker.sock
  Server Version: 26.1.3
  Kernel Version: 6.8.0-1014-azure
  API Version: 1.45
  Operating System: Ubuntu 22.04.5 LTS
  Total Memory: 6.77 GB

[testcontainers.org 00:00:00.18] Reuse is an experimental feature. For more information, visit: https://dotnet.testcontainers.org/api/resource_reuse/
[testcontainers.org 00:00:00.29] Reusable resource not found, create resource
[testcontainers.org 00:00:00.37] Searching Docker registry credential in Auths
[testcontainers.org 00:00:00.37] Searching Docker registry credential in CredHelpers
[testcontainers.org 00:00:00.37] Searching Docker registry credential in CredsStore
[testcontainers.org 00:00:00.37] Searching Docker registry credential in Auths
[testcontainers.org 00:00:00.37] Docker registry credential mcr.microsoft.com not found
[testcontainers.org 00:00:24.42] Docker image mcr.microsoft.com/mssql/server:2019-CU18-ubuntu-20.04 created
[testcontainers.org 00:00:24.52] Docker container 6abc7731610d created
[testcontainers.org 00:00:24.59] Start Docker container 6abc7731610d
[testcontainers.org 00:00:24.99] Wait for Docker container 6abc7731610d to complete readiness checks
[testcontainers.org 00:00:25.00] Execute "/bin/sh -c find /opt/mssql-tools*/bin/sqlcmd -type f -print -quit" at Docker container 6abc7731610d
[testcontainers.org 00:00:25.12] Execute "/opt/mssql-tools/bin/sqlcmd -C -Q SELECT 1;" at Docker container 6abc7731610d
[testcontainers.org 00:00:31.51] Execute "/opt/mssql-tools/bin/sqlcmd -C -Q SELECT 1;" at Docker container 6abc7731610d

...

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

@kakins
Copy link

kakins commented Sep 24, 2024

I confirmed this is still an issue. I just saw it was merged, wasn't sure if a release has been published or not. Anyhow, specifying WithImage("mcr.microsoft.com/mssql/server:2022-CU14-ubuntu-22.04") resolved the issue for now.

@kakins
Copy link

kakins commented Sep 24, 2024

Just a note...

WithImage("mcr.microsoft.com/mssql/server:2022-CU14-ubuntu-22.04") seemed to work most of my pipeline builds using Ubunutu 22.04.5. I did see at least one instance where the SQL server container was timing out on startup.

But it cleared up after stopping the pipeline and starting a new instance

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants