Reputation: 3288
I have a Logstash container that keeps two data sources sync. When it runs, it queries non-synced entries in one database and posts them into the other. I would like to run this container say every 10 seconds.
What I have been doing is to specify --restart=always
so that when the container exits, it restarts itself, around which takes around 5 seconds, which is a bit too often for this use case.
Does Docker support what I want to achieve (waiting X seconds between restarts, or any kind of scheduling) or should I remove the restart policy and schedule it with cron to run every 10 seconds?
Upvotes: 3
Views: 8775
Reputation: 4212
If your container exits succesfully, it will be restarted immediately with --restart=always
An ever increasing delay (double the previous delay, starting at 100 milliseconds) is added before each restart to prevent flooding the server. This means the daemon will wait for 100 ms, then 200 ms, 400, 800, 1600, and so on until either the on-failure limit is hit, or when you docker stop or docker rm -f the container.
Here is your part I guess:
If a container is successfully restarted (the container is started and runs for at least 10 seconds), the delay is reset to its default value of 100 ms.
What you can do is:
Upvotes: 3