https://tecadmin.net/docker-compose-persistent-mysql-data/
by default /var/lib/mysql is default storage for mysql
https://en.wikipedia.org/wiki/Filesystem_Hierarchy_Standard
Create a directory to keep your MySQL data files. I am creating below directory structure under the current directory.
Then configure docker-compose.yml to use ./data/db as volume to store all files created by the MySQL server. Next create compose file in current directory.
docker-compose.yml:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | version: '3' services: db: image: mysql:5.7 container_name: db environment: MYSQL_ROOT_PASSWORD: my_secret_password MYSQL_DATABASE: app_db MYSQL_USER: db_user MYSQL_PASSWORD: db_user_pass ports: - "6033:3306" volumes: - ./data/db:/var/lib/mysql |
No comments:
Post a Comment