Container
Source:
src/Docker/Container.ts
A Docker container managed through the active Docker context.
This resource creates, starts, stops, inspects, and removes containers through
the Docker CLI. It is not interchangeable with Cloudflare.Container, which
manages Cloudflare’s container platform; use pushed image references to bridge
Docker-built images into cloud container runtimes.
Running Containers
Section titled “Running Containers”const nginx = yield* Docker.Container("nginx", { image: "nginx:alpine", ports: [{ external: 8080, internal: 80 }], start: true,});Secret Environment
Section titled “Secret Environment”const password = yield* Config.redacted("POSTGRES_PASSWORD");const db = yield* Docker.Container("postgres", { image: "postgres:18-alpine", environment: { POSTGRES_PASSWORD: password, }, start: true,});Networks and Volumes
Section titled “Networks and Volumes”const network = yield* Docker.Network("app-network");const data = yield* Docker.Volume("postgres-data");const postgresName = "app-postgres";yield* Docker.Container("postgres", { name: postgresName, image: "postgres:18-alpine", ports: [{ external: 15432, internal: 5432 }], volumes: [{ hostPath: data.name, containerPath: "/var/lib/postgresql/data" }], networks: [{ name: network.name, aliases: ["postgres"] }], start: true,});const runtime = yield* Docker.inspectContainer(postgresName);