Idle Container Timeout and Restart Mechanism
I would like to propose a feature enhancement for the caddy-docker-proxy that would significantly optimize resource usage, especially in environments where multiple Docker Compose stacks are deployed.
The requested feature involves the ability to configure idle containers — including those utilizing caddy-docker-proxy labels — to be automatically stopped after a configurable timeout period when no requests are received. When a request is made to the corresponding endpoint, the container should be restarted.
The timeout duration should be adjustable, allowing users to set their own preferences while also including a sensible default, and when a request is made to an idle container that has been stopped, the existing stopped container should be started again without removing it or creating a new instance.
This feature would be particularly beneficial in scenarios where multiple services are running but not all are used simultaneously. By stopping idle containers, we can significantly reduce memory usage and overall resource consumption on the server, leading to improved performance and cost-efficiency.
I have not encountered any existing functionality within the caddy-docker-proxy that provides this capability. Additionally, I have explored possibilities within the base Caddy configuration without finding a feasible solution. However, I’ve noted that similar functionality exists in other projects, such as yusing/go-proxy, which could serve as a reference or inspiration for the implementation.
I believe that implementing this feature would greatly enhance the usability and efficiency of the caddy-docker-proxy. Thank you for considering this request, and thank you for this amazing project. It is really a time-saver and really useful.
Another project I have found after some digging is Sablier, but it is quite the undertaking to set it up.