Skip to content
New issue

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

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

Already on GitHub? # to your account

Testcontainers#exposeHostPorts does not work together with reuse #3457

Closed
jakobbraun opened this issue Nov 10, 2020 · 4 comments
Closed

Testcontainers#exposeHostPorts does not work together with reuse #3457

jakobbraun opened this issue Nov 10, 2020 · 4 comments

Comments

@jakobbraun
Copy link

When reusing a container together with Testcontainers#exposeHostPorts the second container startup fails with an exception.

Example (using testconatienrs 1.15.0):

package com.example;

import org.junit.jupiter.api.Test;
import org.testcontainers.containers.GenericContainer;
import org.testcontainers.junit.jupiter.Testcontainers;

@Testcontainers
public class MyTest {

    @Test
    void test() {
        org.testcontainers.Testcontainers.exposeHostPorts(8000);
        final GenericContainer container = new GenericContainer<>("alpine").withReuse(true).withCommand("top");
        container.start();

        final GenericContainer container2 = new GenericContainer<>("alpine").withReuse(true).withCommand("top");
        container2.start();
    }
}

Result:

org.testcontainers.containers.ContainerLaunchException: Container startup failed
Caused by: org.rnorth.ducttape.RetryCountExceededException: Retry limit hit with exception
Caused by: org.testcontainers.containers.ContainerLaunchException: Could not create/start container
Caused by: com.github.dockerjava.api.exception.DockerException: Status 403: {"message":"endpoint with name objective_benz already exists in network bridge"}

Expected Result:

  • no exception is thrown
  • Host is reachable from inside the container under host.testcontainers.internal:8000
@jbaris
Copy link

jbaris commented Sep 15, 2021

+1

1 similar comment
@yoniw
Copy link

yoniw commented Nov 23, 2021

+1

@sadensmol
Copy link

+1
when you have withReuse turned on, and new container gets started on retry - TC still waits for the previous port, despite new container started on a new one.

@eddumelendez
Copy link
Member

Duplicate #7335

@eddumelendez eddumelendez closed this as not planned Won't fix, can't repro, duplicate, stale Nov 7, 2024
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants