Allow for graceful container stop
See original GitHub issueCurrently I see only 1 method to stop a running testcontainer: org.testcontainers.containers.GenericContainer#stop
. But to my great surprise and dismay that method ends up calling dockerClient.killContainerCmd
. So there is no way for graceful shutdown of running container which would allow for the application running inside it to perform any expected cleanup.
Please, provide a graceful stop.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:10
- Comments:17 (14 by maintainers)
Top Results From Across the Web
Stopping Docker Containers Gracefully - Alen Komljen
Let's try to stop this container with a docker stop test . Docker will kill the container after 10 seconds. If you check...
Read more >Graceful shutdowns with ECS | Containers - Amazon AWS
As part of the shutdown, the application should finish processing all outstanding requests and stop accepting new requests.
Read more >Kubernetes best practices: terminating with grace
1 - Pod is set to the “Terminating” State and removed from the endpoints list of all Services. At this point, the pod...
Read more >Kubernetes Pod Graceful Shutdown — How? | by FoxuTech
In this case, Kubernetes allows the containers running in the pod to get shutdown ... So, with this all those components updates their...
Read more >docker - What does "gracefully stop" mean? - Stack Overflow
Additional: By stopping a container Docker send a SIGTERM to the container. I the container have not stopped in a timeout period the...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
There is
containerIsStopping
that one can use to executestopContainerCmd
. It is also possible to stop the container externally:Also note that stopping and then starting a container won’t work properly (one of the use cases for not killing the container from
stop
), as Docker will assign new random ports and other state adjustments. For those who want to test what happens when the process is restarted, it is recommended to restart the process inside the container and not the container itself.Given this, I suggest we close this issue. @rnorth @kiview WDYT?
I have taken a look how easy it would be for me to propose a PR. I was unable to find a suitable place for my new proposed methods. Currently
container.stop
delegates directly toResourceReaper
. It would be strange if the latter was able to just stop containers, without removing them. So it seems to me that my original wish is not so easy implemented.On the other hand, in our particular case we have found a satisfying workaround (shutting applications down via Spring Boot’s actuator), so this issue does not bother us any more at all.
As a result, I suggest just closing this issue as not relevant.