docker-compose: reinitializing MySQL db every time
<p>We have a Rails app with MySQL as DB. The <code>db</code> part of <code>docker-compose.yml</code> looks like</p>

<pre><code>  db:
    image: mysql
    env_file:
      - ma.env
    volumes:
      - ./dump-db:/docker-entrypoint-initdb.d
      - ./my.cnf:/etc/mysql/my.cnf
    restart: always
    ports:
      - "3306:3306"
    environment:
            - MYSQL_HOST=
</code></pre>

<p>and under <code>./dump-db</code> folder there actually is an sql-dump of our db.</p>

<p>Problem is, we need to have that exact dump loaded each and every time <code>docker-compose up</code> is run. MySQL docker image works in such a way, that it stores it's data on host machine and therefore your db-service is not stateless.</p>

<p><strong>What we need</strong> is that <code>db</code> service discarded all changes done within <code>docker-compose up</code> previous run and fresh-started with that exact dump.</p>