Migrating Container Bind Mounts To Volume On Digital Ocean

Hi,

I have deployed a Self Hosted n8n instance on DigitalOcean following this documentation: Digital Ocean - n8n Documentation

It seems like the storage is a bind mount instead of volume

My concern is that all data might be lost if I would remove the container in order to update n8n (reference: https://community.n8n.io/t/how-to-upgrade-n8n-with-docker-compose-setup/660/2?u=jeremylwf)

Thus would like to how to migrate a container from bind mounts to volume?

Here is my existing docker-compose.yml:

version: "3.7"

services:
  caddy:
    image: caddy:latest
    restart: unless-stopped
    ports:
      - "80:80"
      - "443:443"
    volumes:
      - ${DATA_FOLDER}/caddy_data:/data
      - ${DATA_FOLDER}/caddy_config:/config
      - ${DATA_FOLDER}/caddy_config/Caddyfile:/etc/caddy/Caddyfile

  n8n:
    image: n8nio/n8n
    restart: always
    ports:
      - 5678:5678
    environment:
      - N8N_BASIC_AUTH_ACTIVE=true
      - N8N_BASIC_AUTH_USER
      - N8N_BASIC_AUTH_PASSWORD
      - N8N_HOST=${SUBDOMAIN}.${DOMAIN_NAME}
      - N8N_PORT=5678
      - N8N_PROTOCOL=https
      - NODE_ENV=production
      - WEBHOOK_URL=https://${SUBDOMAIN}.${DOMAIN_NAME}/
      - GENERIC_TIMEZONE=${GENERIC_TIMEZONE}
      - N8N_EMAIL_MODE=smtp
      - N8N_SMTP_HOST=****
      - N8N_SMTP_PORT=*****
      - N8N_SMTP_USER=******
      - N8N_SMTP_PASS=*******
      - N8N_SMTP_SENDER=******
      - N8N_SMTP_SSL=true
      - N8N_LOG_LEVEL=info
      - N8N_LOG_OUTPUT=console
      - N8N_LOG_FILE_COUNT_MAX=100
      - N8N_LOG_FILE_SIZE_MAX=16
    volumes:
      - ${DATA_FOLDER}/.n8n:/home/node/.n8n
      - ${DATA_FOLDER}/local_files:/files

volumes:
  caddy_data:
    external: true
  caddy_config:

Not a Digital Ocean user myself but I know @Jon is. Perhaps he can help with this?

Hi @jeremylwf,

The bind mount is on the local drive of the droplet under /root/n8n-digital-ocean/.n8n, If you SSH into your box you should be able to see it. Personally I prefer this approach over a docker volume but you won’t have anything to worry about your data will still be there after an upgrade.

The problem we see with data not being persisted tends to happen if there is no storage mounted at all, If you wanted to move to a volume instead because of a preference for that approach you can make a new docker volume and manually copy the files from the local storage to the volume then update the compose file to change the data folder to be your volume.

2 Likes