Sharing Data Across Multiple Docker Containers

Hello guys,
I am deploying my Strapi application on AWS with no issues. However, when creating new containers; the data on previous container gets lost (On every deployment, new container is started).
I have 3 alternatives on my mind:

  • Use an external database (I don’t want to unless it is necessary)
  • Use strapi export & import CLI before deployment, which isn’t also a clean way
  • Have some sort of shared folder between containers

For the third option, I don’t know which folders/files should I commonly use so database is persisted amongst multiple containers.
I would like to hear your thoughts about which option to use, and how to make third option work.

Thank you.

This topic has been created from a Discord post (1249699874425802914) to give it more visibility.
It will be on Read-Only mode here.
Join the conversation on Discord

Strapi uses SQLite by default which persists the data in a local file (hence the loss of data between re-deployments)

You can specify the path for the SQLite db in the settings (u should be able to find how in the docs)

Just add it as a Docker volume to persist outside of Docker redeployments

Also make sure u use a similar approach to persist outside of EC2 instances (Idk, EBS?)

It worked perfectly, thank you!