Description
When using DockerComposeContainer
to launch an existing docker-compose file, Testcontainers expose random ports for the services, which can be picked up with the .getServicePort(..., ...)
method.
However, if the docker-compose file includes ports
definitions, Testcontainers will also expose those fixed ports, defeating the purpose of avoiding collisions by randomizing ports.
I am aware that the documentations states that "it is not necessary to define ports to be exposed in the YAML file; this would inhibit reuse/inclusion of the file in other contexts". But at the same time, DockerComposeContainer
is meant to be used in situations where docker-compose files are already in use, and for me, it is convenient that those existing docker-compose files do include the port definitions.
So it would be convenient if Testcontainers could simply ignore the ports in the docker-compose files, and only expose the randomly assigned numbers. As far as I can see, this is not currently an option(?)