Containers
Anything with a Dockerfile, as an always-on service on Fargate or a scale-to-zero Lambda container.
A container app is built from your Dockerfile and listens on a port. Use it for languages other than JavaScript, for frameworks that need a long-lived process, for WebSockets, or when you already have an image.
Two ways to run a container
runtime = "lambda" (default) | runtime = "fargate" | |
|---|---|---|
| Runs on | AWS Lambda with your container image | AWS Fargate, one or more tasks |
| When idle | scales to zero; you pay per request and duration | at least one task always running |
| Request length | up to 15 minutes | unlimited |
| WebSockets, long connections | no | yes |
| Size | up to 10 GB memory | up to 16 vCPU and 120 GB memory |
| Good for | APIs with irregular traffic | steady traffic, sockets, background loops |
lambda is the default; fargate is billed for every hour its tasks are on, so an app chooses it only for what a function cannot do (Functions or containers). Both receive HTTP through CloudFront, so the address, the domain and the release step are the same as for any other app.
What Run needs from your image
- It listens on the port in
PORT(Run sets it, default 8080). - It answers the health check path (
/by default,health_check.pathto change it) with a 2xx within the health timeout. - It writes logs to standard output and standard error.
- On
SIGTERMit finishes in-flight requests within 30 seconds.
Without a Dockerfile, Run can build an image for Node, Python or Go projects with its own buildpacks; the detected settings are printed in the build log.
Releases for containers
A Fargate release starts the new tasks, waits for their health checks, shifts traffic to them and then stops the old tasks. If the new tasks fail their health checks, the release stops and production keeps the old deploy.