2 min read

n8n Docker Export & Import: Copy Workflows and Credentials Between Containers


💡

Quick tutorial on moving n8n data between containers. You’ll learn to export workflows and credentials, copy them out of Docker, and reimport on a fresh instance.

What you’ll learn

  • Set up docker-compose with encryption key and volumes
  • Export workflows with n8n export:workflow --all
  • Export credentials (encrypted or decrypted)
  • Use docker cp to move files in/out of containers
  • Reimport everything on a new instance

Docker Compose setup

Create your .env file with the encryption key:

N8N_ENCRYPTION_KEY=your-generated-key-here

Your docker-compose.yml binds a volume for two-way data access between the container and host:

services:
  n8n:
    image: n8nio/n8n
    environment:
      - N8N_ENCRYPTION_KEY=${N8N_ENCRYPTION_KEY}
      - GENERIC_TIMEZONE=UTC
    volumes:
      - ./data:/home/node/.n8n

Start with:

docker compose up -d

Exporting workflows and credentials

Export all workflows:

docker compose exec n8n n8n export:workflow --all --output=/home/node/.n8n/backups/

Export credentials (encrypted):

docker compose exec n8n n8n export:credentials --all --output=/home/node/.n8n/backups/

Export credentials (decrypted) for moving to a different instance:

docker compose exec n8n n8n export:credentials --all --decrypted --output=/home/node/.n8n/backups/

Copying data out of the container

Use docker cp to copy the backups folder to your host:

docker cp n8n:/home/node/.n8n/backups ./backups

Reimporting on a fresh instance

Copy files back into the container:

docker cp ./backups n8n:/home/node/.n8n/backups

Import credentials first:

docker compose exec n8n n8n import:credentials --input=/home/node/.n8n/backups/

Then import workflows:

docker compose exec n8n n8n import:workflow --input=/home/node/.n8n/backups/

Production note

For production deployments, consider using a tool like Kamal for proper secret management and deployment orchestration. Docker alone lacks the tooling to make credential handling safe at scale.

📧