Thank you for answering.
I understand but i don’t think that docker allows to have a random internal port.
We would have such a workflow:
version: '3.0'
services:
rapid_test_cb:
build:
context: ""
dockerfile: cb.docker
ports:
- "8091" <= this is a fixed internal port with a random external port, otherwise it would be 8091:8091
- "8092"
- "8093"
- "11210"
1: Start the image
2: Inside the image parse the /var/run/docker.sock file to get the exposed port (lots of work and no easy way to do that)
3: Inject those ports into the couchbase server’s conf and start it
4: The client tries to connect to the the exposed port and… failure
Why ?
Well, we would have this:
Exposed random port: 3485 (just an example)
Internal fix port: 8091
Internal couchbase port: 3485 (same as the exposed random port)
Two problems:
- 8091 <> 3485 so it would not work.
- Getting the random exposed ports from within the container is possible but not trivial.
As far as I know, it is not possible to have a random port for both external and internal ports in a docker-compose file. And even if it was the case, the image’s changes are not trivial compared to just having fixed ports at the client level for your integration tests.
I am opened to better ideas or any compromise.