I'm quite new to docker and I try to setup my dev-environment for a simple wordpress site. So my docker-compose.yaml looks like this:
version: '3'
services:
#Database
db:
image: mysql:5.7
volumes:
- db_data:/var/lib/mysql
restart: always
environment:
MYSQL_ROOT_PASSWORD: password
MYSQL_DATABASE: wordpress
MYSQL_USER: wordpress
MYSQL_PASSWORD: wordpress
networks:
- my_network
#Wordpress
wordpress:
depends_on:
- db
image: wordpress:latest
ports:
- '8080:80'
restart: always
volumes: ['./src/:/var/www/html']
environment:
WORDPRESS_DB_HOST: db:3306
WORDPRESS_DB_USER: wordpress
WORDPRESS_DB_PASSWORD: wordpress
networks:
- my_network
networks:
my_network:
volumes:
db_data:
When i run this docker-compose, all works as expected and i know that i can now export my mysql database with:
docker exec <CONTAINER> /usr/bin/mysqldump -u root --password=root <DATABASE> > backup.sql
My Problem: I'm working on different systems and share the project using a self-hosted git (gitea). I did a lot of research and wondered why i could not find any nice way to bring also the volume db_data
into git (All solutions i found do import and export database-dumps). Imo the export and import seem to be unnecessary extra steps (at least for my workflow?)
question from:
https://stackoverflow.com/questions/65842555/docker-compose-share-database-with-git 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…