-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Requested port X is not mapped with jenkins kubernates dind #4307
Comments
Hey @abhishek-rdm, can you please specify how you create the container? |
@kiview sure
|
Thanks. And this test works when running with local Docker? Note that you did not share your call to |
|
|
Just to clarify, you aren't calling From the last answer, it is not clear to me, if you can run the test successfully with a local Docker. Also, did this issue occur after switching to another Testcontainers version, or did it never work with your Jenkins setup? |
Thanks for noticing I just now changed it to Containers.WIREMOCK.getMappedPort(8080), but it still did not work.
Yes, it just works on my local machine and the test cases pass, I did not manage to run it on Jenkins setup, it always fail there. Also, I am using version 1.15.3, but switching to 1.16.0 also results in the same error on Jenkins. |
Exact error when Jenkins inside the kube with the localstack container (4566)
@Shared
public static final LocalStackContainer localstack;
static {
localstack = new LocalStackContainer(localstackImage)
.withServices(LocalStackContainer.Service.SSM, LocalStackContainer.Service.S3,
LocalStackContainer.Service.SECRETSMANAGER)
.withStartupTimeout(Duration.ofSeconds(300))
.withExposedPorts(4566,4571)
.withLogConsumer(new Slf4jLogConsumer(logger))
.waitingFor(Wait.forLogMessage(".*Execution of \"start_api_services\" took.*",1));
localstack.start();
} |
Have you tried Testcontainers 1.16.0? |
Hi @bsideup , Many thanks for your reply, yes I tried with 1.16.0 there, I have't managed to get the tests itslef. mentioning " no bridge network found" --> [EKS with jenkins agent runs a pod]set then I switch back to 1.15.3 pretty much started app able start and execute but the container which spawned doest have the ports exposed despite on the other note, I disabled the ryuk as I couldn't fine a way to enable ryuk port(8080) exposed, therwise I was getting - requested port 8080 not exposed error. here I am pasting the docker inspect where I cant see the exposed ports.
|
@bkosaraju FYI you're getting the same result, just 1.16.0 fails faster - consider keeping it. Also, disabling Ryuk makes no sense if it fails with the same error. Could you please share full output of |
Hi @bsideup , As suggested this time I ran with
Docker Inspect..
|
@bkosaraju so, it looks like your Docker isn't assigning any ports: "PortBindings": {
"8080/tcp": [
{
"HostIp": "",
"HostPort": ""
}
]
}, Which sounds like a problem with Docker, not Testcontainers :) |
Thanks @bsideup , Indeed, this pointed me right direction for investigation. I eventually managed this working with following options.
TESTCONTAINERS_RYUK_DISABLED=true;
TESTCONTAINERS_HOST_OVERRIDE=172.31.0.1 #<-- to avoid bridge network not found private static Network createInternalBridgeNetwork() {
Consumer<CreateNetworkCmd> cmdModifier = (createNetworkCmd) -> {
com.github.dockerjava.api.model.Network.Ipam.Config ipamConfig = new com.github.dockerjava.api.model.Network.Ipam.Config()
.withSubnet("172.31.0.1/24")
createNetworkCmd.withDriver("bridge")
.withIpam(new com.github.dockerjava.api.model.Network.Ipam().withConfig(ipamConfig));
};
return Network.builder()
.createNetworkCmdModifier(cmdModifier)
.build();
}
public static Network network = createInternalBridgeNetwork();
@Shared
public static final LocalStackContainer localstack;
static {
localstack = new LocalStackContainer(localstackImage)
.withServices(LocalStackContainer.Service.SSM, LocalStackContainer.Service.S3,
LocalStackContainer.Service.SECRETSMANAGER)
.withStartupTimeout(Duration.ofSeconds(300))
.withNetwork(network)
.withExposedPorts(4566)
.withPrivilegedMode(true)
.withLogConsumer(new Slf4jLogConsumer(logger))
.waitingFor(Wait.forLogMessage(".*Execution of \"start_api_services\" took.*", 1));
localstack.start();
}```` |
@bkosaraju see https://www.testcontainers.org/features/configuration/#customizing-ryuk-resource-reaper Although I would still try to configure bridge network |
@bkosaraju the solution works for me as well thanks a lot. |
@abhishek-rdm creating a bridge network is a workaround, not a solution. The big question is why the default bridge network is missing. Perhaps you could try configuring the daemon? |
Thanks @bsideup , Sure, certainly configuring bridge is a clean option with two caveats.
that being said, in case if we have an option to specify the network name instead of hardcoded name "bridge" at https://github.com/testcontainers/testcontainers-java/blob/master/core/src/main/java/org/testcontainers/dockerclient/DockerClientProviderStrategy.java#L278 it would be just a config option similar to TESTCONTAINERS_HOST_OVERRIDE, also ryuk would be great help to manage resources. though I configured separately, I feel its not quite right to take lifecycle of container management in to my hands and implement, as we have a well organised ryuk. All in all, at this moment TESTCONTAINERS_HOST_OVERRIDE and RYUK both exclusive to me, and the options can be configured at RYUK, not all available in terms of networks. On the side node I try to override some of the options with custom didn't seems to pick either. |
Description: Requested port X is not mapped when running with Jenkins Kubernetes docker in docker.
Containers.POSTGRES.getMappedPort(X)
Current behavior: Requested port (X) is not mapped
Expected behavior: API should return the assigned port.
Version: 1.15.3
Logs:
testcontainer_logs.txt
The text was updated successfully, but these errors were encountered: