Reputation: 14423
I'm having a little bit of trouble figuring out how to handle deployment changes on database services. Right now, it's as simple as doing:
docker-compose up -d
It rebuilds the containers if there's a change on the config. It's not a problem for my web service (node) since it doesn't have any sort of state. I can pretty much delete everything, bring it back up again and nothing is lost.
My database service is continuously registering new data which is obviously important so i can't just scrap it. As far as I understand, volumes are different every time the images get built. So I would lose all the data every time I rebuild the service.
How should I deal with scheme changes? Or should I update the service manually?
Upvotes: 0
Views: 320
Reputation: 174
You can add a data volume to your container. In this case, you can add a "volumes" properties in you docker-compose.yml
like this:
volumes:
- /opt/mysql/data:/var/lib/mysql
Then the data will be volumed in /opt/mysql/data
on the host.
Upvotes: 1