snippetdockerMinor
How to create a preemptable docker container?
Viewed 0 times
containercreatedockerhowpreemptable
Problem
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 ?
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 ?
Solution
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.
Context
StackExchange DevOps Q#5824, answer score: 1
Revisions (0)
No revisions yet.