-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Open
Description
Typically a Docker image will declare what ports it exposes using:
EXPOSE <ports...>
Why is it also necessary to duplicate this information by default for GenericContainer?
Take the quick start example:
@Rule
public GenericContainer redis = new GenericContainer<>("redis:5.0.3-alpine")
.withExposedPorts(6379);If the user does not explicitly state what ports to expose via withExposedPorts(), could we run DockerClientFactory.instance().client().inspectImageCmd(this.getDockerImageName()).exec(); to run a Docker image inspection and automatically read/set the ports exposed by the Docker image? I know there are situations where a user may not want to expose all (or any) ports of a container, but I think this would be the minority case for Testcontainers users, right?
If we were to do this, the above code example could simply be:
@Rule
public GenericContainer redis = new GenericContainer<>("redis:5.0.3-alpine");