New Tool Radar

AI Agents & Automation

How to Deploy n8n With Docker Compose and Persistent Workflow Data

Deploy n8n with Docker Compose and a data volume so workflows, credentials and executions survive a container restart.

Schematic diagram with three steps: Write the compose file, Add the data volume, then Restart and check.

n8n runs in Docker, but a container without a volume loses its workflows when it is recreated. A Docker Compose file with a data volume keeps the workflows, credentials and executions on the host, so a restart or an upgrade does not wipe the work.

Before you start

You need a server with Docker and Docker Compose. Decide the data folder on the host first, and set its permissions so only the n8n user can read it, because it holds credentials.

Write the compose file with a volume

Write a Docker Compose file with the n8n image, the port mapping and a volume that maps the host data folder into the container. Start it with docker compose up and open the n8n UI to confirm it loads. Create one test workflow and save it.

Restart the container and check the workflow is still there

Stop and recreate the container with docker compose down and docker compose up, then open n8n and check the test workflow is still listed. If it is gone, the volume mapping is wrong: the data went into the container, not the host folder.

Worked example: Persistent deploy for a fictional orders desk

Northwind Orders is a fictional orders desk. Its n8n runs in Docker Compose with a data volume. The table shows the check.

Check Expected
Workflows after restart Test workflow still listed
Credentials after restart Model credentials still saved
Executions after restart Past runs still visible

Expected result (UNTESTED): after the recreate, the test workflow, its credentials and its past executions are all still there. We checked the n8n AI Agent documentation, which describes the agent node that runs on the instance, but we did not deploy the container on this machine.

Limits

A volume keeps the data, but it is not a backup: copy the data folder off the machine regularly. Keep the n8n version pinned in the compose file and read the release notes before an upgrade.

Sources

See all