question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

NetworkMode=host causes starting issue

See original GitHub issue

I use the following code to start a container:

private class CustomOracleContainer
    extends GenericContainer[CustomOracleContainer](
      DockerImageName.parse("mycompany/oracle:enterprise-19.14.0-preloaded-20220120-27-36701e3")
    )

private val oracleContainer: CustomOracleContainer = new CustomOracleContainer()
  .withExposedPorts(1521)
  .withNetworkMode("host")
  .waitingFor(Wait.forLogMessage("DATABASE IS READY TO USE!\\n", 1))
  .withStartupTimeout(Duration.ofSeconds(160))

With testcontainers 1.15.1, it works. When updating to 1.16.3, I get the following error:

ERROR ?.1.0-preloaded-20220120-27-36701e3] - Could not start container
org.testcontainers.shaded.org.awaitility.core.ConditionTimeoutException: Lambda expression in org.testcontainers.containers.GenericContainer: expected the predicate to return <true> but it returned <false> for input of <InspectContainerResponse(...))> within 5 seconds.
	at org.testcontainers.shaded.org.awaitility.core.ConditionAwaiter.await(ConditionAwaiter.java:164)
	at org.testcontainers.shaded.org.awaitility.core.AbstractHamcrestCondition.await(AbstractHamcrestCondition.java:86)
	at org.testcontainers.shaded.org.awaitility.core.ConditionFactory.until(ConditionFactory.java:939)
	at org.testcontainers.shaded.org.awaitility.core.ConditionFactory.until(ConditionFactory.java:645)

Any idea what’s happening ?

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:5
  • Comments:21 (15 by maintainers)

github_iconTop GitHub Comments

2reactions
rgugliel-dacommented, Sep 19, 2022

@rgugliel-da, @javahippie @pretep22, can I confirm what environments you’re on?

The host networking driver only works on Linux hosts, and is not supported on Docker Desktop for Mac, Docker Desktop for Windows, or Docker EE for Windows Server.

Docker docs

I’m considering whether or not to throw an exception (or at least a warning) on non-linux environments when trying to use host mode.

I use Ubuntu.

1reaction
kiviewcommented, Sep 16, 2022

Thank you, then it seems we indeed need to support the network mode. I still don’t understand why the Oracle container requires it in this setup, but since it worked in old Testcontainers versions we introduced a regression for this feature and I believe we should try to restore the fuctionality.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Docker executor fails when network mode is set to host - GitLab
My .gitlab-ci.yml contains a very simple stage, which depends on a service. When I try to execute it with gitlab-ci-multi-runner exec docker ...
Read more >
"host" network_mode is incompatible with port_bindings ...
Hi, I am trying to install a Nuclias container running and getting an error on the port binding. Could anyone suggest what needs...
Read more >
Task definition parameters - Amazon Elastic Container Service
When running tasks that use the host network mode, do not run containers using ... If you have problems using entryPoint , update...
Read more >
Published ports are discarded when using host network mode ...
I am using docker to run Nginx through the Below command: sudo docker run --network=host -p 8443:8443 --rm --name nginx-reverse -v ...
Read more >
Docker Networking 101 – Host mode - Das Blinken Lichten
Recall that docker makes rather extensive use of iptables for it's ... If we run two Apache instances in host network mode one...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found