Moving mariadb to docker installation
I'm running debian jessie and I'm currently trying to replace all my server services with docker containers. After some research, i tried this command:
docker run --name mariadb -v /var/lib/mysql:/var/lib/mysql -d -p 3306:3306 -d mariadb:latest
after stopping the local mariadb service, but this command didn't work. My webapplications didn't have any database access after. How do i currently move all databases? Is there a more secure way?
I just want a drop-in replacement. Starting the docker container and using the mariadb server as I used to.
Answer
Hi,
you can not just start a new instance of mariadb server in a docker container and expect it to work with you "old" mariadb data.
I think this should be done:
- backup local database (logical backup, see url below).
- start docker with a new volume for the new database
- import the SQL dump into the docker database.
Documentation on how to backup your DB:
https://mariadb.com/kb/en/library/backup-and-restore-overview/
Regards,
Faustin