Linux

How to upgrade n8n version using dockerfile

To update n8n when you're running it using a Dockerfile + docker-compose, you have two options depending on whether you're building your own image or using the official n8n image.

1. If you use a custom Dockerfile (like your example)

Your docker-compose.yml shows:

n8n:
  build: .

Meaning it builds from Dockerfile in the same folder.
To update n8n, you must edit Dockerfile to pull a newer version.

Step 1: Update Dockerfile

FROM n8nio/n8n:1.122.5
# Or latest stable:
# FROM n8nio/n8n:latest
# (your custom commands below if any)

Replace the existing version with the newest one.

Step 2: Rebuild the image

Run

docker-compose build --no-cache

Or

docker compose build --no-cache

Step 3: Restart n8n

docker-compose down
docker-compose up -d

That’s it — n8n is updated.

2. If you want to stop using a Dockerfile

You can update easier by using the official image directly:

n8n:
  image: n8nio/n8n:latest   # or a specific version
  restart: always
  ports:
    - "5678:5678"
  environment:
    - N8N_HOST=n8n.yourdomain.com
    - N8N_SECURE_COOKIE=false
    - GENERIC_TIMEZONE=Asia/Ho_Chi_Minh
    - N8N_BASIC_AUTH_ACTIVE=true
    - N8N_PORT=5678

Then update with:

docker-compose pull
docker-compose up -d

3. Confirm the new version

Inside the container:

docker exec -it <container_name> n8n --version

Or in UI → Settings → About.

Thanks for visit my website