Reputation: 1473
First off, I might have formulated the question inaccurately, feel free to modify if necessary.
Although I am quite new to docker and all its stuff, yet somehow managed to create an image (v2
) and a container (cont
) on my Win 11 laptop. And I have a demo.py which requires an .mp4 file as an arg.
Now, if I want to run the demo.py file, 1) I go to the project's folder (where demo.py lives), 2) open cmd and 3) run: docker start -i cont
. This starts the container as:
root:834b2342e24c:/project#
Then, I should copy 4) my_video.mp4 from local project folder to container's project/data folder (with another cmd) as follows:
docker cp data/my_video.mp4 cont:project/data/
.
Then I run: 5) python demo.py data/my_video.mp4
. After a while, it makes two files: my_video_demo.mp4 and my_video.json in the data folder in the container. Similarly, I should copy them back to my local project folder: 6)
docker cp cont:project/data/my_video_demo.mp4 data/
, docker cp cont:project/data/my_video_demo.json data/
Only then I can go to my local project/data folder and inspect the files.
I want to be able to just run a particular command that does 4) - 6) all in one.
I have read about -v
option where, in my case, it would be(?) -v /data:project/data
, but I don't know how to proceed.
Is it possible to do what I want? If everything is clear, I hope to get your support. Thank you.
Upvotes: 0
Views: 60
Reputation: 1473
Well, I think I've come up with a way of dealing with it.
I have learned that with -v
one can create a place that is shared between the local host and the container. All you need to do is that run the docker and provide -v
as follows:
docker run --gpus all -it -v C:/Workspace/project/data:/project/data v2:latest python demo.py data/my_video_demo.mp4
--gpus
- GPU devices to add to the container ('all' to pass all GPUs);
-it
- tells the docker that it should open an interactive container instance.
Note that every time you run this, it will create a new container because of -it
flag.
Partial credit to @bill27
Upvotes: 0
Reputation: 16
You should indeed use Docker volumes. The following command should do it.
docker run -it -v /data:project/data v2
Upvotes: 0