Below is one way you can link your self-hosted Supabase container with your n8n container using Docker networking. The idea is to run both containers in the same Docker network so that n8n can reach Supabase by its container name. Here’s how you can do it:
1. Modify or Create a Docker Compose File
If you haven’t already, create (or adjust) a Docker Compose file that defines both the n8n and Supabase services. For example:
version: "3.7"
services:
n8n:
image: docker.n8n.io/n8nio/n8n
container_name: n8n
ports:
- "5678:5678"
environment:
# n8n environment variables, plus:
# You can optionally pass the Supabase host name if you’d like to keep it in sync.
- SUPABASE_HOST=http://supabase:8000
- NODE_ENV=production
volumes:
- n8n_data:/home/node/.n8n
depends_on:
- supabase
supabase:
image: supabase/postgres
container_name: supabase
ports:
# Expose any ports required by Supabase (adjust if needed)
- "8000:8000"
- "5432:5432"
environment:
POSTGRES_PASSWORD: your_postgres_password
# Add any other necessary environment variables for Supabase
volumes:
n8n_data:
Notes:
- In the example above, we expose Supabase on port 8000 (this port might be the one for the Supabase API—check your Supabase configuration on which port the API is running).
- The
depends_on
directive ensures that Docker starts the Supabase container before n8n.
- Both containers are on the same default network so that n8n can reference Supabase by its container name (here, “supabase”).
2. Configure Supabase Credentials in n8n
Inside n8n (via its Web UI), create or update your Supabase credentials so that they use your local Supabase instance. You’ll typically need to supply:
- Host: Use the internal Docker address. Based on our compose file, that might be
http://supabase:8000
(make sure you adjust the port if your setup is different).
- Service Role Secret: Obtain the Service Role API key from your Supabase instance (or set it during the Supabase setup process) and paste it here.
This configuration instructs n8n to use your local Supabase instance.
3. Start the Docker Compose Setup
From your terminal at the folder containing your docker-compose.yml, run:
This command will start both your n8n and Supabase containers. Because they are on the same network, n8n should be able to communicate with Supabase using the container name supabase
.
4. Verify the Integration
- Open your n8n instance (usually at http://localhost:5678) and test your Supabase workflow node using the credentials you configured.
- If running workflows that depend on Supabase, ensure that the API requests reach the Supabase instance via the local network.
Additional Tips for Novices
- Container Names & Networking: When using Docker Compose, services on the same application network can be referenced by their service (or container) name. That’s why using
http://supabase:8000
in your credentials works.
- Environment Variables: You can pass extra environment variables to n8n if you want to use them in your workflows. They can sometimes help if you want to make the integration configurable.
- Documentation References:
- n8n’s documentation on Supabase credentials shows which fields are needed.
- Supabase’s documentation on self-hosting via Docker explains how to set up Supabase using Docker and update secrets.
Once both services are running in the same network and set up with the correct credentials, your workflows in n8n should be able to make calls to your locally running Supabase instance seamlessly.
Feel free to adjust port numbers or environment variables as needed for your specific setup.