I have an image with MYSQL installed. I need to map the /var/lib/mysql directory to my host system. Following is the screenshot that I see within that directory, when I use the following command
docker run --rm -it --env-file=envProxy --network mynetwork --name my_db_dev -p 3306:3306 my_db /bin/bash
Now when I try to mount a directory from my host ( Windows 10 ), by running another container from the same image, the mysql directory is blank.
docker run --rm -it --env-file=envProxy --network mynetwork -v D:/docker/data:/var/lib/mysql --name my_db_dev1 -p 3306:3306 my_db /bin/bash
Also tried this, but none works
docker run --rm -it --env-file=envProxy --network mynetwork -v D:\docker\data:/var/lib/mysql --name my_db_dev1 -p 3306:3306 my_db /bin/bash
One thing that I see, is that the mysql directory in the path has now root user, instead of mysql as in the previous case.
I wanted all the content from the existing container (mysql directory ) to be copied back to the host mount directory
Is that Possible ? and How can that be achieved ?


If you need to get files from container into host, better use
docker cpcommand: https://docs.docker.com/engine/reference/commandline/cp/It will look like:
docker cp my_db_dev1:/var/lib/mysql d:\docker\dataUPD
In this case you have to:
Start using
docker-composeto orchestrate containers.In
docker-compose.ymlyou create volume, which is shared between all containers. Something like:docker-compose.yml
Description: https://docs.docker.com/compose/compose-file/#volume-configuration-reference