title: How to persist MySQL container on Windows 10 between reboots
body: <p>I'm using a native Docker for Windows (on Windows 10) for WordPress development. I have two containers: WordPress and MySQL. MySQL container has a data volume where DB data is stored between runs.</p>
  
  <p>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.</p>
  
  <p>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?</p>
  
  <p>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. </p>
  
  <p>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 needs this? Am I missing anything here?</p>
  
  <p>Any help really appreciated! Thanks!</p>
  
  <p>P.S. My docker-compose.yml file is:</p>
  
  <pre><code>version: '2'
  
  services:
     db:
       image: mysql:5.7
   ports:
    - "9013:3306"
   volumes:
     - ./database:/var/lib/mysql
   restart: always
   environment:
     MYSQL_ROOT_PASSWORD: somewordpress
     MYSQL_DATABASE: wordpress
     MYSQL_USER: wordpress
     MYSQL_PASSWORD: wordpress
  
     wordpress:
   depends_on:
     - db
   image: wordpress:latest
   volumes:
     - ./wordpress:/var/www/html
   ports:
     - "8013:80"
   restart: always
   environment:
     WORDPRESS_DB_HOST: db:3306
     WORDPRESS_DB_USER: wordpress
     WORDPRESS_DB_PASSWORD: wordpress
     WORDPRESS_TABLE_PREFIX: wpd1_
  </code></pre>