วิธีติดตั้ง n8n และ Docker [สำหรับใช้งานจริง]
Table of Contents
Introduction
This tutorial provides a step-by-step guide on how to install n8n using Docker. n8n is an open-source workflow automation tool that allows you to connect various services and create complex workflows. By using Docker, you can easily deploy n8n in a containerized environment. This guide is designed for practical use and will help you set up n8n for real-world applications.
Step 1: Install Docker and Docker Compose
Before you can run n8n, you need to have Docker and Docker Compose installed on your machine.
-
Install Docker
- Visit the Docker installation page and follow the instructions specific to your operating system (Windows, macOS, Linux).
-
Install Docker Compose
- Docker Compose comes with Docker Desktop on Windows and macOS. For Linux, follow the Docker Compose installation instructions.
Step 2: Create a Docker Compose File
Now, you need to create a Docker Compose file that defines the n8n service and its configuration.
-
Open your terminal or command prompt.
-
Create a new directory for your project:
mkdir n8n-docker cd n8n-docker
-
Create a file named
docker-compose.yml
:touch docker-compose.yml
-
Open the file in a text editor and add the following configuration:
version: '3.8' services: n8n: image: docker.n8n.io/n8nio/n8n container_name: n8n restart: always ports: - "5678:5678" volumes: - n8n_data:/home/node/.n8n environment: - N8N_BASIC_AUTH_ACTIVE=true - N8N_BASIC_AUTH_USER=admin - N8N_BASIC_AUTH_PASSWORD=your_password - TZ=Asia/Bangkok volumes: n8n_data:
- Replace
your_password
with a strong password of your choice.
- Replace
Step 3: Start n8n with Docker Compose
With your docker-compose.yml
file configured, you're ready to start n8n.
-
In your terminal, run the following command:
docker-compose up -d
- This command starts the n8n service in detached mode.
-
Check if n8n is running:
- You can verify that n8n is running by checking the logs:
docker-compose logs -f
Step 4: Access the n8n Interface
After starting n8n, you can access its web interface.
-
Open your web browser and go to:
http://localhost:5678
-
Log in using the credentials you set in the
docker-compose.yml
file:- Username:
admin
- Password:
your_password
- Username:
Conclusion
You have successfully installed n8n using Docker and can now start building workflows. Remember to keep your Docker containers updated and manage your volumes for data persistence. As a next step, explore n8n’s features and consider integrating it with other services to automate your tasks effectively.