1# Docker PostgreSQL Example
2
3This example provisions PostgreSQL 18 Alpine with Docker resources:
4
5- `Docker.RemoteImage` pulls `postgres:18-alpine`
6- `Docker.Network` creates an app network
7- `Docker.Volume` creates persistent database storage
8- `Docker.Container` starts PostgreSQL with a redacted password, a network alias, a named volume, and a host port
9- `Docker.inspectContainer` returns the bound host port
10
11Docker resources use the active Docker CLI context. That can be Docker Desktop, a remote Docker host, an SSH context, or a CI runner daemon.
12
13These resources are separate from `Cloudflare.Container`. The bridge between Docker and cloud container platforms is an image reference or registry digest, not a swappable container object.
14
15## Commands
16
17```sh
18bun install
19POSTGRES_PASSWORD=change-me bun run --filter docker-postgres-example deploy
20bun run --filter docker-postgres-example destroy
21```
22
23If `POSTGRES_PASSWORD` is omitted, the example generates and stores a redacted password with `Alchemy.makeRandom`.
24
25The stack publishes PostgreSQL on `localhost:15432`:
26
27```sh
28psql postgres://alchemy:change-me@localhost:15432/app
29```