Running your own database or engine
You can run PostgreSQL, MySQL, Redis, RabbitMQ or any other engine from a container image you choose, next to your own application, in one environment. Hosting works out the network, readiness and storage for you. You keep the engine itself, including its backups.
If you want Hosting to run the engine and own its backups, use a managed database instead.
The minimum you write
Each image needs only runtime, image and run.port. A private engine adds run.protocol, and one
that keeps data adds a disk. This needs schema 1.25:
version: "1.25"
applications:
db:
runtime: client_image
image: {registryHost: ghcr.io, repository: acme/postgres, reference: "18"}
run: {port: 5432, protocol: postgres}
storage:
- {volume: db_data, mountPath: /var/lib/postgresql}
storage:
db_data: {sizeMib: 10240}
Your application reaches it with DATABASE_URL: {service: db, field: url}. The
full example adds the application,
a password secret, a schedule and a second disk.
What Hosting works out
| Question | What Hosting does | Field, only when you need it |
|---|---|---|
| Public or private? | Routed when the protocol is http (the default) and the application has a route. Any other protocol is private: no public address and no route | run.protocol |
| When is it ready? | http: an HTTP check at healthPath (default /). Anything else: a TCP connect to the port | run.healthPath |
| Is it alive? | No liveness check, so a database replaying its log after a crash is not restarted mid-recovery | — |
| What is its address? | {service: <app>, field: host|port|url}. url is <protocol>://host:port, or host:port for tcp. No credentials are in it | — |
| Who may connect? | Only the applications whose document references it. Everything else is refused | — |
| Where is its data? | One storage claim per disk, on single-server storage | storage.<name>.sizeMib |
Before you apply, the preview's Inferred section shows each of these answers.
hostingctl environment references <environment-uuid> lists each image with its host, port and url.
Disks and their lifecycle
- An image can mount up to eight disks, at any absolute path, such as
/var/lib/postgresqlor/var/lib/rabbitmq. A path that covers the image's own system files (/etc,/usr/bin,/procand similar) is refused by name. - A disk belongs to one application.
- A deploy of an image with a disk stops the running copy before the new one starts, so expect a short interruption.
- Growing a disk is allowed. Shrinking one is refused, because storage only grows.
- Renaming a disk, or the application that mounts it, creates a new empty disk. The old disk keeps its data.
- Removing a disk from the document, or removing the application, keeps its data in the environment, unmounted. It still counts against your package's storage until you release it, which deletes the disk and its data.
The preview names each of these before anything changes.
Backups are yours
Hosting does not back up a disk your own image writes to. Copying a running database's files is not a
backup, because the files can be mid-write. Use the engine's own dump tool, such as pg_dump or
mysqldump. Run it on a schedule: a cron entry of the database application itself, which reaches the
database through a reference to its own application ({service: db, field: url}), and uploads the dump to
your own bucket. A schedule runs in a Pod of its own and does not see the database's disks, so the dump
goes to the bucket rather than to a disk. Test that you can restore from it.
Licences
You are responsible for the licences of the images you import.
Examples
The hosting-examples repository holds working documents,
including api-and-own-database and postgres-custom-image. Each README lists the hostingctl commands
to preview, apply, check and remove the example.