Open csokol opened 6 years ago
For reference, I was able to find a hacky solution by resetting the container cache through reflection:
public class CustomDockerComposeRule extends ExternalResource {
private DockerComposeRule delegate;
public CustomDockerComposeRule(DockerComposeRule delegate) {
this.delegate = delegate;
}
@Override
protected void before() throws Throwable {
ContainerCache containerCache = delegate.containers().containerCache();
FieldUtils.writeField(containerCache, "containers", new HashMap<>(), true);
delegate.before();
}
@Override
protected void after() {
delegate.after();
}
}
I'm facing a similar problem reported in #200. After a bit of debugging, it seems like the rule doesn't call stop/start or the containers are cached in
ContainerCache
between two tests. So if the rule runsdocker compose down
thendocker compose up
, the ports might change and this doesn't get reflected in the container objects.I noticed this problem when trying to create a base class with a shared docker compose rule config.
For example:
docker-compose.yml
Here's the output when I run both tests:
Any ideas on how to fix it?