score:4

Accepted answer

original java library has answer to your port question.
https://www.testcontainers.org/features/networking/

note that this exposed port number is from the perspective of the container.

from the host's perspective testcontainers actually exposes this on a random free port. this is by design, to avoid port collisions that may arise with locally running software or in between parallel test runs.

because there is this layer of indirection, it is necessary to ask testcontainers for the actual mapped port at runtime. this can be done using the getmappedport method, which takes the original (container) port as an argument

in scala library you can get this mapped port by calling

container.mappedport(yourexposedport) 

error is most likely related to this concept, you need to expose that port in advance, inside your docker image. make sure that you either have expose 8080 command somewhere in your dockerfile or any image that is used to build yours have it


Related Query

More Query from same tag