Deffiss / testenvironment-docker

MIT License
117 stars 30 forks source link

Starting "Mongo" Container throws - failed to create shim: OCI runtime create failed #65

Closed kumarnmanoj closed 2 years ago

kumarnmanoj commented 2 years ago

Error Trace


Message: 
Docker.DotNet.DockerApiException : Docker API responded with status code=InternalServerError, response={"message":"failed to create shim: OCI runtime create failed: container_linux.go:380: starting container process caused: process_linux.go:545: container init caused: sethostname: invalid argument: unknown"}

  Stack Trace: 
DockerClient.HandleIfErrorResponseAsync(HttpStatusCode statusCode, HttpResponseMessage response, IEnumerable`1 handlers)
DockerClient.MakeRequestAsync(IEnumerable`1 errorHandlers, HttpMethod method, String path, IQueryString queryString, IRequestContent body, IDictionary`2 headers, TimeSpan timeout, CancellationToken token)
ContainerOperations.StartContainerAsync(String id, ContainerStartParameters parameters, CancellationToken cancellationToken)
ContainerApi.CreateContainer(ContainerParameters containerParameters, CancellationToken cancellationToken)
ContainerApi.RunContainerAsync(ContainerParameters containerParameters, CancellationToken cancellationToken)
Container.RunAsync(CancellationToken cancellationToken)
DockerEnvironment.UpAsync(CancellationToken cancellationToken)
BookStoreServiceIntegrationTest.InitializeAsync() line 62

Code


     public async Task InitializeAsync()
        {
            _environment = CreateTestEnvironmentBuilder().Build();

            await _environment.UpAsync();

            _container = _environment.GetContainer<MongoContainer>("BookStoreServiceIntegrationTestMongo");
        }

        private IDockerEnvironmentBuilder CreateTestEnvironmentBuilder()
        {
            var builder = new DockerEnvironmentBuilder()
                .SetName("BookStoreServiceIntegrationTest")
                .AddMongoContainer(p => p with
                {
                    Name = "BookStoreServiceIntegrationTestMongo"
                });

            return builder;
        }

Environment:

  1. Windows
WindowsProductName WindowsVersion OsHardwareAbstractionLayer
------------------ -------------- --------------------------
Windows 10 Pro     2009           10.0.19041.1566
  1. WSL
 wsl --list
Windows Subsystem for Linux Distributions:
docker-desktop (Default)
docker-desktop-data
  1. Dotnet Environment - .net6
kumarnmanoj commented 2 years ago

Observed the same error in the azure devops pipeline with the Ubuntu Image.

kumarnmanoj commented 2 years ago

We figured that the issue is because of the length of the names. We shortened the name as below, it started to work

        public async Task InitializeAsync()
        {
            _environment = CreateTestEnvironmentBuilder().Build();

            await _environment.UpAsync();

            _container = _environment.GetContainer<MongoContainer>("TestMongo");

            Console.WriteLine(_container);
        }

        private IDockerEnvironmentBuilder CreateTestEnvironmentBuilder()
        {
            var builder = new DockerEnvironmentBuilder()
                .SetName("BSSIntegrationTest")
                .AddMongoContainer(p => p with
                {
                    Name = "TestMongo"
                });

            return builder;
        }
Deffiss commented 2 years ago

I guess I can close the issue now