How to upgrade a docker without loosing the data

I’m just starting with Docker. I have a very easy and basic question, I believe. I’ve seen lots of images that are dockerized databases. If I use them in production and, for some reason, I need to update the image. How can I do it in a easy way? Do I need to export and re-import the data?

We generally suggest to split up your containers into separate functions, allowing your application containers to be immutable, or at least ephemeral.

So for database containers, we’d place the persistence files (ie, the backend storage) into a separate volume container which is then linked to the database container using --volumes-from