How to prevent database docker from being rebuilt and losing production data How to prevent database docker from being rebuilt and losing production data docker docker

How to prevent database docker from being rebuilt and losing production data


This is what data volumes are for. There is a whole page on the docker documentation site covering this.

The idea is that when you destroy the container, the data volume persists with data on it, and when you restart it the data hasn't gone anywhere.I will say though, that putting databases in docker containers is hard. People have done it and had severe dataloss and severe jobless.

I would recommend reading extensively on this topic before trusting your production data to docker containers. This is a great article explaining the perils of doing this.