All Collections › Docker Clusters › Databases and accessories

Databases and accessories

Run PostgreSQL, Redis, Valkey, Typesense, Meilisearch and other services as containers

Updated

On a Dockerfile cluster, the databases Hatchbox manages and the services your apps need run as containers on your servers, each with its data on a Docker volume. The server runs nothing but SSH and Docker.

Databases

Give a server a PostgreSQL, MySQL, Redis, Valkey, Memcached or Elasticsearch role and Hatchbox starts the engine's official image on it. Backups, the stats page, restarts, password resets and PostgreSQL major version upgrades work as they do on any other cluster.

Valkey is only offered on Dockerfile clusters. It's the open-source Redis fork, speaks the same protocol and gets the same REDIS_URL, so a Redis client needs no change.

The env vars Hatchbox writes carry the server's private address, which every server in the cluster reaches, or the container's name (hatchbox-postgresql, hatchbox-redis and so on) on a server without a private network. If you write a connection string yourself, use one of those rather than localhost, which inside a container means the container itself. Your firewall rules for the database ports apply as usual.

A PostgreSQL upgrade moves your data to the new version in place with pg_upgrade, and takes about as long as a restart for most databases. Connections are refused while it runs.

External databases, like a managed PostgreSQL service, work as they do anywhere else. Containers connect out through the server's own IP address, so if the service only accepts listed addresses, add your servers' IPs.

Accessories

A search engine or another service your apps need can run as a container beside them. On the cluster page, Add accessory offers Typesense and Meilisearch, filled in and with a key generated, or a custom image with your own port, command, env vars and data directory. Pick the server it runs on. Its data lives on a Docker volume there named <name>_data, which outlives the container and any change of image.

Attach an accessory to an app from the accessory's page, and the app gets the env vars to reach it:

  • Typesense: TYPESENSE_HOST, TYPESENSE_PORT, TYPESENSE_PROTOCOL and TYPESENSE_API_KEY
  • Meilisearch: MEILISEARCH_HOST and MEILISEARCH_API_KEY
  • A custom image: <NAME>_HOST and <NAME>_PORT

Change the prefix if your app reads other names.

Saving new settings replaces the container on the same volume, which is how you upgrade. Removing an accessory stops it and takes its env vars out of the attached apps, but keeps the volume for you to delete with docker volume rm when you're sure. Deleting a server warns you which accessories run on it, and autoscaling never removes a server that runs one.

The API manages accessories at /api/v1/clusters/:cluster_id/accessories: list, show, create (a kind of typesense or meilisearch fills in the rest), update, delete, POST …/:id/restart, and POST or DELETE …/:id/attachment with an app_id and an optional prefix.