Access file of windows machine from docker container

11,518

Solution 1

Of course, you can use volumes.

For example, you can run the following command:

docker run -v path/to/your/file/on/host:path/to/the/file/on/container your_image

Solution 2

The only approach to access the host file is that you can mount the host directory of host system . like if you have

c:\project\test.txt

you can mount c:\project to the docker .

docker run -v c:/project:/src images
By this way you will we able to access the c:project files inside the src folder of the container . or you can create the folder in container and mount it .

And files in container will we accessible to you in /src folder of container and you can do any operation with that file inside the container

Share:
11,518

Related videos on Youtube

Rakesh K
Author by

Rakesh K

Web developer.

Updated on September 16, 2022

Comments

  • Rakesh K
    Rakesh K over 1 year

    I have installed Docker Desktop for Windows in Windows 10 operating system. I am running a python script inside docker container which reads file from disk and add few text at the end of files. Now the requirement is to read files from Windows 10 and perform the same operation on it.

    Is it possible in docker to read files from OS on top of which Docker is running?