| 1 | # Container |
| 2 | |
| 3 | A Durable Object that supervises a container. The object extends the |
| 4 | `Container` class from `@cloudflare/containers`, and the image is the |
| 5 | `Dockerfile` beside it: a small Python HTTP server on port 8080. |
| 6 | |
| 7 | Install the dependency, then run the example. `celld dev` builds the image |
| 8 | with the Docker or Podman CLI on your `PATH` and starts the container the |
| 9 | first time a request reaches the object: |
| 10 | |
| 11 | ```sh |
| 12 | npm install |
| 13 | celld dev |
| 14 | curl http://127.0.0.1:9876/container/alpha |
| 15 | curl http://127.0.0.1:9876/container/beta |
| 16 | curl http://127.0.0.1:9876/lb |
| 17 | ``` |
| 18 | |
| 19 | Each path under `/container/` is one object, and each object runs one |
| 20 | container. The response carries the container's hostname, so two paths show |
| 21 | two containers. `/lb` spreads requests over three containers. |
| 22 | |
| 23 | Deploy to a fleet from this directory. `celld deploy` saves the image to the |
| 24 | bucket, and each node loads it the first time a cell of the class starts: |
| 25 | |
| 26 | ```sh |
| 27 | celld deploy . --bucket s3://my-cells-bucket |
| 28 | ``` |
| 29 | |
| 30 | Every node that serves the class needs a container engine: a Docker or |
| 31 | Podman daemon on its default socket, or the socket named by `DOCKER_HOST`. |
| 32 | |
| 33 | The class declares `instance_type: "basic"`, a quarter of a CPU and 1 GiB. |
| 34 | Without a type a container gets Cloudflare's `dev` type, a sixteenth of a |
| 35 | CPU, and this server takes about four seconds to start on it instead of |
| 36 | under one. |