I have a folder in my linux server where i get one new file every hour. So i had to make a python script which has to monitor this folder to check for the file. If the file is placed in the folder, the script should access the file and process it. Now I have to containerize this python script. So my question is, how can i access the folder which is outside the docker container ?? My script should continuously check the file in a folder which is outside the container. Please help on this
Asked
Active
Viewed 227 times
0
-
I believe that you should mount the folder/volume to access it – CyDevos Jan 17 '22 at 14:54
-
https://stackoverflow.com/a/23455537/2836621 – Mark Setchell Jan 17 '22 at 14:55
-
For the workflow you're describing, it sounds like Docker's filesystem isolation might not be a good match. In addition to the bind-mount suggestion, consider running the program directly on the host, or setting up an HTTP server inside the application (for example, using Flask) and using a tool like `curl` to send the file to the container instead of using shared files. – David Maze Jan 17 '22 at 14:57
1 Answers
0
you would need to map the volume to the container
# Run a container using the `alpine` image, mount the `/tmp`
# directory from your host into the `/container/directory`
# directory in your container, and run the `ls` command to
# show the contents of that directory.
docker run \
-v /tmp:/container/directory \
alpine \
ls /container/directory

Alik.Koldobsky
- 334
- 1
- 10