Services built by a real sysadmin.

Every product in this shop was tested in production, optimized under pressure, and designed to make your infrastructure safer, faster, and cleaner.

Browse services

How to Safely Update n8n in a Docker Container (2025 Guide)

Locate docker containers:

docker ps

You should see Caddy reverse proxy and N8N container.

CONTAINER ID   IMAGE          COMMAND                  CREATED          STATUS          PORTS                                                                                             NAMES
8d3a13c59a08   n8nio/n8n      "tini -- /docker-ent…"   13 minutes ago   Up 6 minutes    0.0.0.0:5678->5678/tcp, [::]:5678->5678/tcp                                                       n8n
8917b5af4d16   caddy:latest   "caddy run --config …"   4 weeks ago      Up 37 minutes   0.0.0.0:80->80/tcp, [::]:80->80/tcp, 0.0.0.0:443->443/tcp, [::]:443->443/tcp, 443/udp, 2019/tcp   n8n-docker-caddy-caddy-1

Locate volume data:

root@docker-n8n-droplet:~/.n8n# docker volume ls
DRIVER    VOLUME NAME
local     caddy_data
local     n8n_data

In my case data is located at n8n_data.


Backup it up (replace n8n_data with your volume name):

docker run --rm -v n8n_data:/data -v "$HOME/n8n-volume-backup:/backup" alpine sh -c "cd /data && tar czf /backup/n8n_data_backup.tar.gz ."

Stop N8N Container

docker stop <container_id>

Remove the old N8N container (doesn’t remove data):

docker rm <container_id>

WARNING: Do not remove Caddy container, Caddy is a web server which acts as reverse proxy n8n container.

Create docker-compose.yml inside ~/.n8n folder.

mkdir ~/.n8n

Place this inside docker-compose.yml:

version: "3.7"

services:
  n8n:
    image: n8nio/n8n
    container_name: n8n
    restart: unless-stopped
    ports:
      - "5678:5678"
    environment:
      - N8N_HOST=n8n.domain.com
      - N8N_PORT=5678
      - N8N_PROTOCOL=https
      - WEBHOOK_URL=https://n8n.domain.com/
      - GENERIC_TIMEZONE=Europe/Belgrade
    volumes:
      - n8n_data:/home/node/.n8n

volumes:
  n8n_data:
    external: true

Replace n8n_data with the name of your volume, replace n8n.domain.com with your actual domain name.

Download latest N8N

cd ~/.n8n
docker compose pull

Run N8N

cd ~/n8n
docker compose up -d

Fix Caddy IP

The IP of docker container for N8N will change, if inside your Caddyfile you have an IP set, instead of a hostname, this need to be changed.

From docker ps get container ID for Caddy. Run:

docker exec -it <container_id> sh
vi /etc/caddy/Caddyfile

Use this:

n8n.domain.com {
    reverse_proxy http://n8n:5678 {
      flush_interval -1
    }
}

Usually instead of n8n you will see the IP.
Put in n8n.

Restart Caddy

docker restart <container_id>

Reconnect docker network

docker network create n8n_net
docker network connect n8n_net <n8n_container_id>
docker network connect n8n_net <caddy_container_id>

This should help update N8N that is running inside a docker on any setup 🙂

If you run into questions of issues you can leave a comment or contact me. Thanks.

Need Expert Help?

If you’re still having issues with your server or network setup, let’s fix it together. Schedule a one-on-one consultation now.

Schedule a Consultation

Comments

One response to “How to Safely Update n8n in a Docker Container (2025 Guide)”

  1. Petar Avatar
    Petar

    Thanks a lot Luka this is a lifesaver!

Leave a Reply

Your email address will not be published. Required fields are marked *