Stopped Docker Compose Container - database.sqlite is missing

I am running n8n via docker compose on Ubuntu and have been using it for a several versions. I did have to replace traefik with my own reverse proxy, but that hasn’t caused any issues. Everything was going great, until I stopped the container today and started it back up. Everything is now missing.

I am directed to the /setup page like it’s my first time running n8n.

Looks like my persistent volume should be /root/n8n/.n8n:/dockervols/n8n, but that directory on my host OS completely empty.

Here’s my docker-compose.yml:

version: "3"

services:

  n8n:
    image: n8nio/n8n
    restart: always
    ports:
      - "127.0.0.1:5678:5678"

    environment:
      - N8N_BASIC_AUTH_ACTIVE=false
#      - N8N_BASIC_AUTH_USER
#      - N8N_BASIC_AUTH_PASSWORD
      - N8N_HOST=${SUBDOMAIN}.${DOMAIN_NAME}
      - N8N_PORT=5678
      - N8N_PROTOCOL=http
      - NODE_ENV=production
      - WEBHOOK_URL=https://${SUBDOMAIN}.${DOMAIN_NAME}
      - WEBHOOK_TUNNEL_URL=https://${SUBDOMAIN}.${DOMAIN_NAME}
      - VUE_APP_URL_BASE_API=https://${SUBDOMAIN}.${DOMAIN_NAME}
      - GENERIC_TIMEZONE=America/New_York
    volumes:
      - ${DATA_FOLDER}/.n8n:/dockervols/n8n

and here’s my .env file:

# Folder where data should be saved
DATA_FOLDER=/root/n8n/

# The top level domain to serve from
DOMAIN_NAME=aiscorp.com

# The subdomain to serve from
SUBDOMAIN=n8n

# DOMAIN_NAME and SUBDOMAIN combined decide where n8n will be reachable from
# above example would result in: https://n8n.example.com

# The user name to use for authentication - IMPORTANT ALWAYS CHANGE!
N8N_BASIC_AUTH_USER=corey

# The password to use for authentication - IMPORTANT ALWAYS CHANGE!
N8N_BASIC_AUTH_PASSWORD=passwordgoeshere

# Optional timezone to set which gets used by Cron-Node by default
# If not set New York time will be used
GENERIC_TIMEZONE=Europe/Berlin

# The email address to use for the SSL certificate creation
[email protected]

N8N_EMAIL_MODE=smtp
N8N_SMTP_HOST=10.4.2.253
N8N_SMTP_USER=cmcmillan
N8N_SMTP_PASS=passwordgoeshere
[email protected]

Looking at my bash history, I’ve only ever run ‘sudo docker compose up -d’ so it should have always run as root.

I’ve searched all over the OS for anything named database.sqlite but can’t find it anywhere.

I fully expect all my workflows are gone, but I’d love to know how this happened. So I don’t loose them again if I rebuild them all…

It looks like your topic is missing some important information. Could you provide the following if applicable.

  • n8n version:
  • Database (default: SQLite):
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app):
  • Operating system:

The volumes are incorrect. It should be something like this

volumes:
      - ${DATA_FOLDER}:/home/node/.n8n

Considering that the volume wasn’t mounted into the correct path inside the container, it’s very likely that /home/node/.n8n was a part of the container’s ephemeral filesystem, and whenever the container got recreated via docker compose, those files were deleted by docker.

Looking at the stack, and the env variables, this doesn’t look anything like any of the compose file n8n recommends. where did you get these values from?

Thanks @netroy I figured that’s what happened. I’ve been using n8n since at least version 0.220.0. I copied this config from an older instance, which at the time I got from the docker compose deployment guide. I’m not sure, but it sounds like when n8n went to version 1, the running user switched to node from root, and therefore would have just happily ignored my mounted volume.

Anyway, I’ve got a lot of rebuilding to do. Thanks again for your help.

n8n did switched to node user a while before 1.0, but the /dockervols/n8n folder was likely incorrect even on older versions.

Unless N8N_USER_FOLDER was overwritten, the data has always been written to the .n8n folder in the user’s home directory (so either /root/.n8n or /home/node/.n8n).