3

How to restart a container with every interval timeout in docker-compose.yml by an option?

This is my simplified docker-compose.yml:

version: '3'

services:
  ivms_app:
      build: .
      image: an_image
      container_name: app_name
      restart: unless-stopped

      ports:
        - "9001:9001"

I have set the restart option with unless-stopped attribute. But I want an option for restarting a container with every interval timeout in docker-compose.yml like this:

interval_restart: 30 # 30 minutes

Benyamin Jafari
  • 21,522
  • 19
  • 109
  • 128
  • I don't think there is a way to do this kind of configuration in the `docker-compose.yml` file. Have you tried anything else? For example a `cron` job which will run a script every 30 minutes that does what you want? Related: [How to restart a single container with docker-compose](https://stackoverflow.com/questions/31466428/how-to-restart-a-single-container-with-docker-compose). – tgogos Nov 26 '18 at 11:14
  • 1
    I'm curious that under what context do you want to have this behavior? – Siyu Nov 26 '18 at 12:25

0 Answers0