← All articles

Tools3 min read

Install n8n locally with Docker and build your first workflow

Run n8n with Docker Compose, keep your data and build a first workflow that validates and routes a sample request.

Igor Karmazin · AI Technical Product Operations

n8n: first workflow

This guide runs n8n locally and builds a workflow that checks a sample request. You can finish the exercise with synthetic data and no external credentials.

Install n8n with Docker Compose

Start Docker Desktop or install Docker Engine and Compose. On Windows, use Docker Desktop with WSL2 and work from WSL. Run docker compose version. Create a directory called n8n-local and save this as compose.yaml:

services:
  n8n:
    image: docker.n8n.io/n8nio/n8n:2.46.7
    ports:
      - "127.0.0.1:5678:5678"
    volumes:
      - n8n_data:/home/node/.n8n

volumes:
  n8n_data:

This is a minimal local editor setup. The image tag is pinned for reproducibility. Check stable releases and back up your data before upgrading. The named volume stores configuration, SQLite and the default credential encryption key. Binding the port to 127.0.0.1 keeps the editor local. n8n Docker documentation.

From that directory, run:

docker compose up -d
docker compose ps
docker compose logs --tail=40 n8n

Open http://localhost:5678 and create the local owner account on first use. If port 5678 is busy, change the first port number to 5679 and open that port in the browser.

Build a request routing workflow

  1. Create a workflow and add Manual Trigger so Execute Workflow starts it.
  2. Add Edit Fields (Set) in Manual Mapping mode. Set requestId to DEMO-001 and message to We need a site for our workshop.
  3. Add an If node. Use a String condition, enter {{ ($json.message ?? '').trim() }} in Expression mode and select is not empty.
  4. Add an Edit Fields (Set) node to each output. Set status to ready on true and needs_review on false. Enable Include Other Input Fields on both so requestId is preserved.
  5. Run the workflow. Expect DEMO-001 with status ready. Clear the message or enter only spaces and run again. Expect needs_review.

If the workflow takes the wrong branch, inspect the If node's input, the field name and the condition mode. See the Manual Trigger and Edit Fields references.

Stop, back up and extend the workflow

Use docker compose stop to stop the container and docker compose up -d to start it again. The docker compose down -v command deletes the volume. Back up the volume with the instance stopped before an upgrade. A workflow JSON export lets you move the workflow, while restoring the instance also requires the data and encryption key.

For a second exercise, replace the manual trigger with a test webhook or form. Before connecting a real destination, send the same request ID twice and decide how you will prevent duplicate records. For server deployment, plan for HTTPS, restricted access and backups. Official Compose deployment guide.

FAQ

Do I need an API key?

The local setup and the first workflow use no external APIs. A connected model or service may require a key later.

Does this work on Windows?

Yes. For Docker, use Docker Desktop with WSL2 and follow the n8n guidance on keeping the project inside the WSL filesystem.

Will a restart delete my workflows?

The workflows persist as long as you keep and reuse the named volume.

When should I add an AI model?

Add one when the task needs interpretation, such as extracting information from a free-form message. Keep explicit checks for required fields in the workflow.

Compare n8n and Make · Build an AI agent

Read on Telegram