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!!!

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

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

$ 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