Sunday, April 5, 2020

Docker Machine mapping host drive to container

    To share files between the host and Docker container, we need to map a directory in the host to a path in the container using the below option with docker run

-v path_in_the_host:path_in_the_container

    This command works within linux system, but does not directly work on Docker Machine. One easy workaround is put your folder in C:\Users in your Windows host. Then using the below command

docker run -dit -v /c/Users/folder_name:/mnt/data --name container_name image_name

    After this, your folder "folder_name" in C:\Users will be accessible in the container through /mnt/data.

No comments:

Post a Comment