chore: support for deciding when to auto-export the image ports in case no exposed ports are passed#3159
Open
mdelapenya wants to merge 15 commits intotestcontainers:mainfrom
Open
Conversation
It's covered by a tc property, so it's not a breaking change
✅ Deploy Preview for testcontainers-go ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
…ners#3161) * feat: add a new functional option to append wait strategies to modules * chore: update modules * docs: make it mkore clear
* main: feat(couchbase): adding auth to couchbase initCluster functions to support container reuse (testcontainers#3048) chore(deps): bump github.com/containerd/containerd/v2 (testcontainers#3167) docs(options): refactor options layout in modules (testcontainers#3163) fix(ci): do not run sonar for Testcontainers Cloud (testcontainers#3166) chore(ci): do not fail fast in the Testcontainers Cloud run (testcontainers#3164) feat: support adding wait strategies as functional option (testcontainers#3161)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
This PR adds support for enabling/disabling auto-exposing the port from the container image (default is true: ports are automatically exposed).
This new setting can be configured at the properties level (using the
tc.auto.expose.portsproperty) or with an env var (TESTCONTAINERS_AUTO_EXPOSE_PORTS).When set to true, which is the default, the exposed ports in the image are automatically exposed to the container. When set to false, they are not.
This behavior was present in tc-java in the past (basically
-Pflag, publish all exposed ports), but we removed it, because it created bugs on Windows with running out of ports in a specific range over time. Given that bug is still open in Docker for Windows, we decided to not publish all ports, or at least let users configure it.On the other hand, we are simplifying the auto-exposure of all the ports: instead of inspecting the image and merging the ports with the user request, we set the
PublishAllPortsoption to true in the hostConfig modifier.Why is it important?
Simplify code, and also reduce the chances to get the bug described in docker/for-win#11584
Related issues