I’m using a native Docker for Windows Community Edition Version 17.03.1-ce-win12 (12058) on Windows 10 Pro x64 for WordPress development. I have two containers: WordPress and MySQL. MySQL container has a data volume where DB data is stored between runs. It is configured as:
I start containers with ‘docker-compose up -d’ and stop еруь with ‘docker-compose down’. When stopped this way, MySQL data is saved properly to the data volume and when I start it next time I see all my changes persisted.
However, if I reboot Windows 10 without stopping MySQL containers first, it seems that changes made to the database since the last start are not saved. Docker for Windows is smart enough to start the same volumes that were running before reboot but does it really not care about shutting them down properly so the DB data be saved? Is it really so or do I misunderstand anything?
What is the most reliable way to avoid losing data on a system reboot? Stopping all MySQL container manually before reboot is a tedious task, especially when multiple servers are running. Probably I can create a script that will parse ‘docker ps’ output and will stop all the MySQL containers before reboot but I’m afraid I am probably reinventing a wheel here.
What’s the best way to deal with a situation? I’ve searched high and low but found nothing on a topic. Am I the only one who is having this issue? Am I missing anything here? Should the container’s data be saved automatically to the volume by Docker on Windows reboot or not?
Any help really appreciated! Thanks!