How can I run my node.js process with a permanent sqlite database? How can I run my node.js process with a permanent sqlite database? docker docker

How can I run my node.js process with a permanent sqlite database?


how can I make it so the SQLite databases stay persistent?

When you run your container, use the docker run -v option to mount some sort of external storage to hold the database. It helps if the database file is in a directory that doesn't also have application source in it.

docker run -v $PWD/db:/usr/src/test/db ...

Maintaining file storage in Docker can be a little bit hairy (and this gets worse if you're ever going to look at a clustered system like Docker Swarm or Kubernetes) and you should consider using a "real" relational database in a second container.

should [I] use VOLUME []

Unless you're 100% clear on what it does and why you want it, no, you should not use VOLUME in your Dockerfile. It mostly only has confusing side effects. You can mount external files or named volumes into your container as shown above without any VOLUME declarations.