Docker: How to mount a partition to the container

I tried to mount the partition(/dev/mmcblk0p2) using mount to a local directory(/home/root/data) and gave that directory in the docker run command:

mount /dev/mmcblk0p2 /home/root/data
#mmcblk0p2 is a ext4 partition
docker run -d -v /home/root/data:/home/root/ []

There is a sample app in the container(mount_test) which creates a file in /home/root/sample.txt inside the container and writes some data to it. But after running the above command the directory /home/root/data is still empty. My intention is to have the data stored to the mounted partition(/dev/mmcblk0p2).

After i unmounted the the drive i can see sample.txt is created in /home/root/data/sample.txt in docker host.

Can anyone tell me what mistake i am doing?


Source: Docker Questions