1

I have deployed services using docker stack deploy in two nodes. I would like to know is there a way to specify the duration of time for which each service should run using a compose file or in some other ways (may be a using an option while deploying the stack). Basically the stack should be removed after the specified time.

Thank you in advance.

1 Answers1

0

Using Docker Compose features, no. Docker Compose is intended to run and manage services, but you cannot tell Docker Compose "remove this stack after X time".

However you can use another tool (such as a cron job or an external script) which will call docker-compose down or stop on your stack after it was run a specified time, or a more complex task manager which will leverage Compose itself.

Pierre B.
  • 11,612
  • 1
  • 37
  • 58