2

Is there any way by which I can set a lifetime for a container after that much of time it should be stopped automatically and only awake when someone send a request. I wanted something like Preemptable Google Compute engine instance or Heroku free Dyno which sleeps after 1 hr of inactivity and awake again when a request is send to that instance.

Note: I have docker compose project so I want to set the life time for one service which depends on other services also. I have a traefik container runs separately beside the docker-compose project which handles the request and sends to containers. So is there something like request_post_hook which can start that stopped docker-compose container when receive any request ?

1
  • This reads like you are trying to make something like AWS Lambda, Google Cloud Functions or Azure Functions. It’s not clear why you need the service to be stopped. We would assume so that you don’t have to pay for it. In which case using the “official solution” for pay-as-you-go computation at google would be a good solution. Note that such solutions are actually expensive in terms of the actual cost of the compute but cheap in the sense that you can use tiny amounts only on demand. Any large service that would run the processing logic continuously wouldn’t save money.
    – simbo1905
    Commented Jan 2, 2019 at 13:27

1 Answer 1

1

I'm not aware of any straightforward way to do that, without also running a different container to act as a middleware of sorts. You might want to look at one of the "Serverless" platforms. If your use case will fit that model, many of the docker/swarm/kubernetes serverless tools do what you're asking, but again, you're running other container(s) to manage it. I'd suggest starting with a glance at the OpenFAAS docs to see if it'll work for you.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.