# Containers

> Anything with a Dockerfile, as an always-on service on Fargate or a scale-to-zero Lambda container.

Applies to: the Sypnia engine (open source, self-hosted) and Sypnia Cloud (paid service).  
Source: https://run.docs.sypnia.com/apps/containers/

For agents: Containers in Run: built from Dockerfile (or Run buildpacks for Node/Python/Go); runtime lambda (default: Lambda container image, scale to zero, ≤15 min, ≤10 GB) or fargate (always-on tasks, unlimited request length, WebSockets, up to 16 vCPU/120 GB). Requirements: listen on PORT (default 8080), health check path, logs to stdout/stderr, graceful SIGTERM in 30 s. Fargate releases are health-checked blue/green.

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](https://run.docs.sypnia.com/architecture#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.path` to change it) with a 2xx within the health timeout.
- It writes logs to standard output and standard error.
- On `SIGTERM` it 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.
