I'm facing an issue where my Docker container sometimes hangs and becomes completely unresponsive. When this happens:
I can't stop the container using docker stop <container_id>.
I can't retrieve logs using docker logs <container_id>.
The only way I've been able to resolve this so far is by restarting the entire Docker service:
sudo systemctl restart docker
While this works, it's not ideal because it affects other running containers as well.
My questions:
Is there a way to forcefully stop or remove a hanged container without restarting the Docker service? How can I diagnose what is causing the container to hang? Is it an issue with the application, API, resource limits (CPU, memory), or something else? Can changing the update policy (e.g., --update-order with start-first or stop-first) prevent such hangs, or help in any way? What tools or techniques can I use to monitor and debug containers to identify the root cause? Any help or guidance on how to stop hanged containers and trace the cause would be greatly appreciated!