-
Notifications
You must be signed in to change notification settings - Fork 45
Open
Description
Hello,
I have following code written in C#:
const string workingDirectory = "/app";
var randomHttpsHostPort = new Random().Next(49152, 65535);
_container = new ContainerBuilder()
.WithImage($"{configuration.ImageUrl}")
.WithWorkingDirectory(workingDirectory)
.WithPortBinding(8080, 8080)
.WithPortBinding(randomHttpsHostPort, 8443)
.WithResourceMapping(new FileInfo("localhost.key"), new FileInfo(workingDirectory + "/localhost.key"))
.WithResourceMapping(new FileInfo("localhost.pem"), new FileInfo(workingDirectory + "/localhost.pem"))
.WithEnvironment(new Dictionary<string, string>
{
["ServerCertificate__CertificatePemFilePath"] = $"{workingDirectory}/localhost.pem",
["ServerCertificate__KeyPemFilePath"] = $"{workingDirectory}/localhost.key",
})
.WithWaitStrategy(Wait.ForUnixContainer().UntilPortIsAvailable(8080))
.WithOutputConsumer(Consume.RedirectStdoutAndStderrToConsole())
.Build();I configured .WithResourceMapping according to newest docs update of testcontainers-dotnet, which is also described in Best practices as it copies file to container before start. This setup works correctly with local docker installation.
Hovewer, when I try to run above configuration with kubedock, I'm getting strange issue that pod already exists:
[testcontainers.org 00:00:00.20] Connected to Docker:
Host: tcp://kubedock:2475/
Server Version: 0.18.1
Kernel Version:
API Version: 1.25
Operating System: kubernetes
Total Memory: 0.00 GB
[testcontainers.org 00:00:00.47] Docker container 49676c249464 created
[testcontainers.org 00:00:00.48] Add file to tar archive: Content length: 1703 byte(s), Target file: "/app/localhost.key"
[testcontainers.org 00:00:00.49] Copy tar archive to container: Content length: 1703 byte(s), Docker container: 49676c249464
[testcontainers.org 00:00:00.49] Add file to tar archive: Content length: 1118 byte(s), Target file: "/app/localhost.pem"
[testcontainers.org 00:00:00.49] Copy tar archive to container: Content length: 1118 byte(s), Docker container: 49676c249464
[+0/x0/?0] IntegrationTests.dll (net9.0|x64) - 3 tests running (3s)
fail: IntegrationTests.TestContainer[0]
Container start failed: DockerApiException: Docker API responded with status code=InternalServerError, response={"message":"pods \"kubedock-49676c249464\" already exists"}
fail: IntegrationTests.TestContainer[0]
Container state: Undefined
warn: IntegrationTests.TestContainer[0]
Container not in valid state to retrieve logs
fail: IntegrationTests.TestContainer[0]
Full exception
Docker.DotNet.DockerApiException: Docker API responded with status code=InternalServerError, response={"message":"pods \"kubedock-49676c249464\" already exists"}
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 DotNet.Testcontainers.Clients.TestcontainersClient.CopyAsync(String id, IResourceMapping resourceMapping, CancellationToken ct)
at DotNet.Testcontainers.Clients.TestcontainersClient.RunAsync(IContainerConfiguration configuration, CancellationToken ct)
at DotNet.Testcontainers.Containers.DockerContainer.UnsafeCreateAsync(CancellationToken ct)
at DotNet.Testcontainers.Containers.DockerContainer.StartAsync(CancellationToken ct)
at IntegrationTests.TestContainer.StartAsync() in /home/runner/_work/IntegrationTests/TestContainer.cs:line 21
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels