Docker Community Forums

Share and learn in the Docker community.

Proper Docker Architecture Flask and SQLite

I have a really simple two page data driven Flask website where the data is modified daily. Currently, I am using a python script to update a SQLite database.

What is the best way to dockerize this simple Web application? Should I using one docker container with both the flask app process and a cron job to kickoff the reload of the refresh of the SQLite databse?

Or could I use two dock containers with links and or a common data volume. The data is refreshed completely each day, however it is acquired from multiple source and needs to be joined and aggregated each day.

Thanks fo your feedback.


Ideally, your app and the database are always in separate containers. Maybe I’m missing something in your question, though…about sharing a “common data volume.” With two containers, the flask app should just reference the db service with a depends_on value to connect to the database.

1 Like

Last time I checked sqlite was a file based embedded database.
It does not run as a service (=does not listen on a network port).

A seperation between an application and an embedded database is not possible, unless you rewrite your application to support other databases. You will need to switch to a standalone rdbms like mysql, mariadb or postgres in order to seperate your app from the database and run them in seperate containers.


Ahh, that’s what I missed…I just read right past the type of db. So yes…there’s nothing to put in a second container, just a sqllite file that should be on a volume. Not sure that I would run any kind of production on sqllite, though.

We can only hope that they are already on volume :wink:

Using an embedded database with more that one client application at a time can and eventualy will lead to data incosistency or corruption. No risk, no fun, right?

1 Like

Gotcha… it appears, I have choosen the wrong database.

I will either look at running a cron script in the same container as the Flask app, or choose a client server database.