Self-hosting Supabase lets you run your own backend services. This gives you full control over your data and setup without relying on external servers.
Self-hosting Supabase
docker-compose.yml version: '3.6' services: supabase-db: image: supabase/postgres:latest ports: - '5432:5432' environment: POSTGRES_PASSWORD: yourpassword supabase-api: image: supabase/gotrue:latest ports: - '9999:9999' depends_on: - supabase-db environment: GOTRUE_DB_DRIVER: 'postgres' GOTRUE_DB_DATABASE_URL: 'postgres://postgres:yourpassword@supabase-db:5432/postgres' supabase-realtime: image: supabase/realtime:latest ports: - '4000:4000' depends_on: - supabase-db environment: DB_HOST: supabase-db DB_PORT: 5432 DB_USER: postgres DB_PASSWORD: yourpassword DB_NAME: postgres
This example uses Docker Compose to run Supabase services locally.
Replace yourpassword with a strong password you choose.
version: '3.6' services: supabase-db: image: supabase/postgres:latest ports: - '5432:5432' environment: POSTGRES_PASSWORD: examplepass
version: '3.6' services: supabase-api: image: supabase/gotrue:latest ports: - '9999:9999' depends_on: - supabase-db environment: GOTRUE_DB_DATABASE_URL: 'postgres://postgres:examplepass@supabase-db:5432/postgres'
This Docker Compose file runs the main Supabase services: database, authentication API, and realtime server. It uses a password you set to secure the database. You can start all services by running docker-compose up in the folder with this file.
version: '3.6' services: supabase-db: image: supabase/postgres:latest ports: - '5432:5432' environment: POSTGRES_PASSWORD: mysecretpassword supabase-api: image: supabase/gotrue:latest ports: - '9999:9999' depends_on: - supabase-db environment: GOTRUE_DB_DRIVER: 'postgres' GOTRUE_DB_DATABASE_URL: 'postgres://postgres:mysecretpassword@supabase-db:5432/postgres' supabase-realtime: image: supabase/realtime:latest ports: - '4000:4000' depends_on: - supabase-db environment: DB_HOST: supabase-db DB_PORT: 5432 DB_USER: postgres DB_PASSWORD: mysecretpassword DB_NAME: postgres
Always use strong passwords for your database to keep data safe.
Make sure Docker and Docker Compose are installed before running the configuration.
Self-hosting means you handle updates and backups yourself.
Self-hosting Supabase gives you full control over your backend.
You use Docker Compose to run Supabase services easily on your machine or server.
Remember to secure your database and manage the services regularly.
Practice
Solution
Step 1: Understand self-hosting meaning
Self-hosting means you run the service on your own machine or server, giving you control.Step 2: Compare benefits
Unlike hosted services, self-hosting lets you manage data and backend fully, but requires maintenance.Final Answer:
You get full control over your backend and data. -> Option DQuick Check:
Self-hosting = full control [OK]
- Thinking self-hosting means no maintenance needed
- Assuming self-hosting is always free
- Confusing self-hosting with automatic scaling
Solution
Step 1: Identify Docker Compose usage
Supabase self-hosting uses Docker Compose to manage multiple services together.Step 2: Recall correct Docker Compose command
The command to start services in detached mode isdocker compose up -d.Final Answer:
docker compose up -d -> Option BQuick Check:
Start services with docker compose up -d [OK]
- Using 'docker start' which starts single containers only
- Typing 'supabase start' which is not a Docker command
- Using 'docker run' which runs a new container, not compose
services:
db:
image: supabase/postgres:latest
api:
image: supabase/api:latest
depends_on:
- dbWhat happens if you run
docker compose up?Solution
Step 1: Understand depends_on behavior
Thedepends_onmeans api waits for db container to start before launching.Step 2: Analyze docker compose up effect
Runningdocker compose upstarts all defined services; api waits for db as specified.Final Answer:
Both db and api services start, with api waiting for db. -> Option AQuick Check:
depends_on makes api wait for db [OK]
- Thinking depends_on delays start until db is ready (it waits only for start)
- Assuming api won't start without volumes (not required here)
- Believing only one service starts by default
Solution
Step 1: Identify cause of connection error
Database connection errors usually mean the database service is down or unreachable.Step 2: Verify database service status
Check if the database container is running and network settings allow access.Final Answer:
Check if the database service is running and accessible. -> Option CQuick Check:
Database connection error = check DB service [OK]
- Assuming reinstalling Docker fixes connection errors
- Changing API image without checking DB status
- Disabling firewall without confirming network issues
Solution
Step 1: Identify security best practices
Strong passwords, network restrictions, and SSL protect data from unauthorized access.Step 2: Evaluate other options
Default ports and open IPs increase risk; disabling auth or unencrypted backups are unsafe.Final Answer:
Use strong passwords, restrict network access, and enable SSL connections. -> Option AQuick Check:
Secure DB = strong passwords + network + SSL [OK]
- Leaving default ports open to the internet
- Disabling authentication for convenience
- Not encrypting backups or storing them insecurely
Ready to prove it?
Pass the test and this pattern moves unknown
