Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it necessary to mount volume to databases on docker?

Tags:

docker

I'm new to docker. Been reading some but still don't get it much. Basically if I mount a volume it will be persistent on my hard drive so that my container service can write down and save datas. Seen a lot of container services that is mounted with volumes, like jenkins. But If I have mariadb, do I need to mount a volume to it? What happens if I stop and start the mariadb container?

like image 718
Antonow297296 Avatar asked Dec 14 '25 05:12

Antonow297296


1 Answers

If you just stop and start the data will not be lost.

All data will be deleted when you delete and recreate the container.

Answering your question. It is not strictly necessary to mount a volume for a persistent service (e.g: database). But it is a recommended practice, it will ease scenarios like changing the container (upgrading).

like image 85
Gonzalo Matheu Avatar answered Dec 16 '25 23:12

Gonzalo Matheu



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!