I want to start off with that I'm discovering docker now for a few days. I have setup a docker-compose.yml with a stack that I run for development on my local machine. In my docker-compose.yml I have also created a mysql-container with a volume that connects a folder in my project to the mysql folder that is living in the container.
project structure:
Project
|-- project folder 1
|-- project folder 2
|-- project folder 3
|-- docker
| `-- mysql
|-- file1
|-- file2
`-- docker-compose.yml
container:
mysql:
image: mysql:5.7
ports:
- "3306:3306"
restart: always
environment:
MYSQL_DATABASE: xxx
MYSQL_USER: xxx
MYSQL_PASSWORD: xxx
MYSQL_ROOT_PASSWORD: xxx
networks:
- network-woo
volumes:
- ./docker/mysql:/var/lib/mysql
I push this project to git. A devil called "newbie" on my shoulder tells me "great! this way you are saving the database in the git repo each time you push". While there is an angel called "gutfeeling" that tells me be careful! This could go horribly wrong, but i'm not sure what yet.
My question is if this is a safe method, and if anyone can foresee any troubles with this method in the future. I am aware that if I would put this project on a live server, and pull the git repo onto that server it would overwrite the database with the changes made in the local database, still working on a solution for that one.
Thanks in advance,
Bram