Upgrading n8n in Docker Without Losing Data

Oct 22, 2026
By Admin
2 min read
58 views
Upgrading n8n in Docker Without Losing Data

Upgrading n8n in Docker Without Losing Data

This guide explains how to upgrade n8n running in Docker to the latest version, while preserving your workflows and credentials.

Important: Replace n8n.example.com in the commands with your own domain or subdomain.


Step 0: Optional — Run Docker Without sudo

By default, Docker requires sudo for every command. To avoid this, add your user to the Docker group:

sudo usermod -aG docker $USER

Log out and log back in for the changes to take effect. After this, you can run docker commands without sudo.


Step 1: Stop and Remove the Old Container

docker stop n8n
docker rm n8n

Step 2: Remove All Unused Images and Layers

This will delete all unused Docker images, including old n8n layers.

docker image prune -a

To also clear unused networks and build cache, run:

docker system prune -af

Note: This does not remove volumes, so your data volume will remain intact.


Step 3: Confirm the Data Volume Exists

List all volumes:

docker volume ls

You should see an entry like:

local   n8n_data

For more details, inspect the volume:

docker volume inspect n8n_data

Step 4: Run the New Container with Your Existing Volume

Start a new container that uses the existing data volume:

docker run -d --name n8n \
  --restart=always \
  -p 5678:5678 \
  -v n8n_data:/home/node/.n8n \
  -e N8N_HOST=0.0.0.0 \
  -e N8N_PORT=5678 \
  -e WEBHOOK_URL=https://n8n.example.com/ \
  -e VUE_APP_URL_BASE_API=https://n8n.example.com/ \
  docker.n8n.io/n8nio/n8n:latest

If the image is not available locally, Docker will download the latest version before creating the container.

Remember to replace n8n.example.com with your actual domain or subdomain.


Step 5: Verify the Upgrade

Check the container logs:

docker logs -f n8n

Then open your browser and visit:

https://n8n.example.com/

Your workflows and credentials should still be available.

Share this article:
Back to Blog

More Engineering Articles

View All

Ready to Engineer Scalable Systems for Your Enterprise?

Our engineering team builds custom ERPs, ISP billing platforms, fintech automation, and cloud architectures tailored to your business.

Get in Touch