# Self-host FerretDB

> A MongoDB compatible database that stores documents in PostgreSQL. Runs FerretDB with a bundled PostgreSQL that has the DocumentDB extension, a persistent volume and a generated password. It is not published on the host, so reach it from other services in this project at ferretdb:27017.

- Page: https://levelrail.com/templates/ferretdb/
- JSON: https://levelrail.com/templates/ferretdb.json
- Category: Database Tools
- Licence: Apache-2.0 (Permissive license)
- Source: https://github.com/FerretDB/FerretDB
- Upstream docs: https://docs.ferretdb.io/

## Requirements
- Memory: about 512 MiB
- amd64: unknown, arm64: unknown
- Needs configuration before start: no
- Pinned image tag: 2.7.0

## Services

| Service | Image | Tag | Ports | Volumes |
| --- | --- | --- | --- | --- |
| ferretdb | ghcr.io/ferretdb/ferretdb | 2.7.0 | 27017 | none |
| postgres | ghcr.io/ferretdb/postgres-documentdb | 17-0.107.0-ferretdb-2.7.0 | none | pgdata -> /var/lib/postgresql/data |

## Environment

| Service | Variable | Kind |
| --- | --- | --- |
| ferretdb | FERRETDB_POSTGRESQL_URL | generated |
| ferretdb | FERRETDB_TELEMETRY | preset |
| postgres | POSTGRES_DB | preset |
| postgres | POSTGRES_PASSWORD | generated |
| postgres | POSTGRES_USER | preset |

## Deploy

### CLI

```bash
levelrail-cli templates deploy ferretdb --name my-ferretdb
```

### API

```bash
curl -X POST -H "Authorization: Bearer $TOKEN" \
  https://levelrail.example.com/api/v1/service-templates/ferretdb/deploy
```

Create a token in the dashboard first. This one-click route deploys it as a trial app you can keep or remove.

## First run
1. Read the generated password from the app secrets, then connect with a MongoDB client as the ferretdb user from a service in the same project.

## Questions

### Can I deploy FerretDB on Dokploy or Dokku?

The services and pinned images on this page can be run on any Docker host. The public Dokploy templates list we compared does not have an entry with the same id for FerretDB, so on Dokploy you would use a Docker Compose application with the file from this page. Dokku deploys container images with its own commands, so the pinned image ghcr.io/ferretdb/ferretdb:2.7.0, ghcr.io/ferretdb/postgres-documentdb:17-0.107.0-ferretdb-2.7.0 is what you deploy there.

Self-host FerretDB, FerretDB docker compose file, deploy FerretDB on a VPS: this page lists the pinned image, ports, volumes and the commands for each.
