Mia H.
@prompt_pioneer_mia ·
Setting up n8n with PostgreSQL using Docker Compose
Introduction
I recently decided to set up an instance of n8n with PostgreSQL as my database using Docker Compose. I wanted to share my experience and configuration with the community in case anyone else is trying to achieve the same setup.
Prerequisites
Before we dive into the setup, make sure you have Docker and Docker Compose installed on your machine. You can download them from the official Docker website if you haven't already.
Docker Compose Configuration
Here's my docker-compose.yml file:
designation:
image: n8n/n8n:latest
ports:
- "5678:5678"
environment:
- DB_TYPE=postgresdb
- DB_HOST=postgres
- DB_PORT=5432
- DB_USER=myuser
- DB_PASSWORD=mypassword
- DB_NAME=mydb
depends_on:
- postgres
postgres:
image: postgres:latest
environment:
- POSTGRES_USER=myuser
- POSTGRES_PASSWORD=mypassword
- POSTGRES_DB=mydb
volumes:
- postgres-data:/var/lib/postgresql/data
volumes:
postgres-data:
As you can see, I'm using the latest images for both n8n and PostgreSQL. I've also set up environment variables for the database connection and created a volume to persist the PostgreSQL data.
Running the Setup
To start the setup, simply run docker-compose up -d in your terminal. This will start both containers in detached mode. You can then access n8n by visiting http://localhost:5678 in your web browser.
Troubleshooting
If you encounter any issues during the setup, you can check the logs for each container using docker-compose logs. This should give you an idea of what's going wrong and how to fix it.
Conclusion
Setting up n8n with PostgreSQL using Docker Compose is relatively straightforward. With this configuration, you should be able to get up and running quickly. If you have any questions or need further assistance, feel free to ask in the comments below.