This project offers a straightforward and secure method to run n8n with Docker Compose on Ubuntu.
n8n is an open-source workflow automation tool that allows you to connect various applications and services to automate tasks without writing code.
This guide will help you deploy n8n locally using Docker Compose, ensuring your data is persistent and easily manageable.
- Docker installed
- Docker Compose installed
- An existing Docker volume for persistent data (see below)
-
Clone this repository
git clone https://github.com/mehdimahmoud/n8n-docker.git cd n8n-docker -
Create the Docker volume (optional)
This step is optional, as the volume would be created in step 4 from the docker-compose.yml file.docker volume create n8n_data
-
Set the n8n version
Edit the.envfile to specify the desired n8n version:N8N_VERSION=1.97.1
-
Start n8n using Docker Compose
docker compose up -d
- Open your browser and go to: http://localhost:5678
docker compose logs -fdocker compose stopdocker compose start-
Edit
.envand changeN8N_VERSIONto the desired version. -
Pull the new image and recreate the container:
docker compose pull docker compose up -d
docker run --rm -v n8n_data:/data -v $(pwd):/backup ubuntu bash -c 'tar czvf /backup/n8n_data_backup_$(date +%Y%m%d_%H%M%S).tar.gz -C /data .'# List available backup files
ls -lh n8n_data_backup_*.tar.gz
# Restore a specific backup (replace the filename with the desired timestamped backup)
docker run --rm -v n8n_data:/data -v $(pwd):/backup ubuntu bash -c "cd /data && tar xzvf /backup/n8n_data_backup_YYYYMMDD_HHMMSS.tar.gz --strip 1"docker compose downThis removes the container but keeps the
n8n_datavolume.
-
Your workflows and credentials are stored in the
n8n_dataDocker volume. -
To remove all data, delete the volume:
docker volume rm n8n_data
- n8n Documentation
- n8n GitHub Repository
- n8n Getting Started (YouTube)
- n8n Workflows Playlist (YouTube)
- n8n Community Forum
- Docker Documentation
- Docker Volumes Documentation
- Docker Networking Documentation
- Docker Security Best Practices
- Docker Compose Documentation
- Docker Compose Best Practices
- Docker Compose Environment Variables

