We have a Rails app with MySQL as DB. The db part of docker-compose.yml looks like
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=
and under ./dump-db folder there actually is an sql-dump of our db.
Problem is, we need to have that exact dump loaded each and every time docker-compose up 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.
What we need is that db service discarded all changes done within docker-compose up previous run and fresh-started with that exact dump.