Migrating Docker data containers

Hi All,
I have say created a Docker data container that has some mysql data in it. This is in AWS Ec2 instance. Now I wan’t to move it to Azure cloud VM. I can create the Docker data container there but I would like to know how do I move MySql data thats there currently present in my AWS Ec2 data docker container.
Appreciate any leads on it!!!
Cheers
Karthik.

I’d recommend to use mysqldump to generate a SQL file for your existing database, then executing that .sql file against the new DB instance. You can either use exec on the existing container for this, or simply run a new container.

Something like:

$ docker network create dbnet
94e52b3049dab06cd34e5e4f092f41fb27d856872ed537b994f6ab774daf8114

$ # Assume original DB was run on dbnet network
$ docker run -d --name db --net dbnet -e MYSQL_ROOT_PASSWORD=password mysql 
449cf6343865692ef9f330d6787a9a7ea0050bd38a724e2d0d36d810f1747e76

$ docker run --net dbnet mysql mysqldump --host db [options] >backup.sql

$ # Copy the .sql file to the new (Azure) VM
$ # Assume our new DB container is also named "db"
$ docker exec db mysql < backup.sql