Reading a file into docker


I’m using this for my analysis. Using this method I can pull an image of face_recognition and run it. Now, I want to call a video file, which is located in my windows laptop. How to access the file?

The snippet of the code as follows:

import face_recognition
import cv2
video_capture = cv2.VideoCapture("C:/Users/username/Desktop/folder/Raw_Data/What's Next from Barack and Michelle Obama.mp4")

Thank you!


I way around to solve this problem is the following:

Step 1: Make sure that your “share drive” is connected with the docker. To check if it is there are not, go to “setting” --> “share drive”. It should be check-marked. If you now “ls” from your docker powershell, you will find all the local files showing as list of files.

Step 2: “cd” to location of the folder where file exists. This is not necessary but for convenience

Step 3: Write the following command:

docker cp ./"videofile.mp4" face:/

“face” is the name of the container I want to copy the local file into. And I’m copying it into root directory. If anyone wants to copy it to another directory just put the path after “/”.

Step 4: To get back into original container, use these 2 commands:

docker start  face
docker exec -it face /bash/bin

Now if you “ls”, the you will find that the files you copied are there.

Finally just put the “path of the copied file” in “cv2.VideoCapture” and you are done!!