testcontainers / testcontainers-java

Testcontainers is a Java library that supports JUnit tests, providing lightweight, throwaway instances of common databases, Selenium web browsers, or anything else that can run in a Docker container.
https://testcontainers.org
MIT License
8.01k stars 1.65k forks source link

`com.github.dockerjava.api.exception.ConflictException` when calling stop on a container #2102

Closed jennyowen closed 4 years ago

jennyowen commented 4 years ago

I use TestContainers for unit testing a docker image, and we find that sometimes we get the following stack trace in tests when calling container.stop() within the test:

java.lang.reflect.UndeclaredThrowableException
    at com.neo4j.docker.TestBasic.killContainer(TestBasic.java:33)
Caused by: java.lang.reflect.InvocationTargetException
    at com.neo4j.docker.TestBasic.killContainer(TestBasic.java:33)
Caused by: com.github.dockerjava.api.exception.ConflictException: 
{"message":"Cannot kill container: bfb40a1e621564d4af8a4f56c7eb2dece42227a6c1ea99354b26d159b77a6f06: Container bfb40a1e621564d4af8a4f56c7eb2dece42227a6c1ea99354b26d159b77a6f06 is not running"}

    at com.neo4j.docker.TestBasic.killContainer(TestBasic.java:33)

That's all the stack trace I have unfortunately.

An example test that gives this error is: https://github.com/neo4j/docker-neo4j/blob/54d1bd4d4e63508309ffeaf90561c47157be67c2/src/test/java/com/neo4j/docker/TestBasic.java#L80 (Run on a neo4j enterprise container eg neo4j:3.5-enterprise otherwise the test won't pass).

https://github.com/neo4j/docker-neo4j/pull/210

stale[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If you believe this is a mistake, please reply to this comment to keep it open. If there isn't one already, a PR to fix or at least reproduce the problem in a test case will always help us get back on track to tackle this.

bsideup commented 4 years ago

@jennyowen do you still observe this issue with the latest releases of Testcontainers?

jennyowen commented 4 years ago

I updated to 1.12.5 last week and we haven't seen the problem, but it was fairly sporadic to begin with and the fixes I made to my own tests also reduced the number of times this happened quite significantly.

In the interest of clearing up your backlog feel free to mark this as closed. Thank you for responding and fixing it!

stale[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If you believe this is a mistake, please reply to this comment to keep it open. If there isn't one already, a PR to fix or at least reproduce the problem in a test case will always help us get back on track to tackle this.

stale[bot] commented 4 years ago

This issue has been automatically closed due to inactivity. We apologise if this is still an active problem for you, and would ask you to re-open the issue if this is the case.