简体   繁体   English

每天安排 Docker 容器重启/重置

[英]Schedule daily Docker container restart / reset

I have a Linux based Docker container running an application which seems to have a memory leak.我有一个基于 Linux 的 Docker 容器运行一个似乎有 memory 泄漏的应用程序。 After around a week requests to the application start to fail and the container requires a restart to reset its state and get things working again.大约一周后,对应用程序的请求开始失败,并且容器需要重新启动以重置其 state 并让一切恢复正常。

The error reported by the application is:应用程序报告的错误是:

java.lang.OutOfMemoryError: Java heap space

Is there a generic method that can be used to trigger a restart, resetting it's state, regardless of which service is being used to host it?是否有一种通用方法可用于触发重新启动,将其重置为 state,无论使用哪个服务来托管它? If there's not a good generic solution, I'm about to give DigitalOcean a whirl so maybe there's a DigitalOcean specific solution that may work instead?如果没有一个好的通用解决方案,我将试一试 DigitalOcean,所以也许有一个 DigitalOcean 特定的解决方案可以代替?

You can set a restart policy (with flag on-failure ) as described here .您可以设置重启策略(带有标志on-failure ),如此所述。

Check out the Watchtower project.查看瞭望塔项目。 This is an incredible tool that restarts Docker containers on schedule and also updates containers automatically.这是一个令人难以置信的工具,可以按时重新启动 Docker 容器并自动更新容器。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM