HH0718 Posted January 7, 2020 Share Posted January 7, 2020 Hello everyone. I have created a python script that runs indefinitely. It downloads security camera PNGs from a url and saves it to a folder called images. I wanted to run this on my Unraid docker but seem to have trouble. I created the dockerfile with the following content. FROM python:3.8 RUN pip install --upgrade pip COPY main.py / COPY requirements.txt . RUN pip install -r requirements.txt CMD [ "python", "./main.py"] and I have the following sanitized python 3 script import itertools import pendulum import requests source = {"source_1": "Source=1_URL", "source_2": "Source=2_URL"} for k, v in itertools.cycle(source.items()): print(k, v) image_url = v img_data = requests.get(image_url) img_name = f"images/{k}_{pendulum.now().format('YYYY_MM_DD_HH.mm.ss')}.png" with open(img_name, 'wb') as handler: handler.write(img_data.content) When I create the docker image, I added the `/images` path where the container path is `/images' and the host path is a share i made under '/mnt/user/BH/' if I run it and look in the share, there is nothing at all. But if I console into the running image, I see the images. Can anyone help me understand what I need to do to place the images in the shared folder? I have a feeling I didn't setup the Dockerfile correctly or maybe I need to change the path to my python script. Thanks for your help. Quote Link to comment
itimpi Posted January 7, 2020 Share Posted January 7, 2020 Are you sure the full path inside the container is really /images (i.e. it as at the top level of the container file system) ? The code you posted has no leading / on the name which means it is a path relative to the current folder. When you console into the container you might want to check with the pwd command what is the current folder. Quote Link to comment
HH0718 Posted January 7, 2020 Author Share Posted January 7, 2020 (edited) Thanks for the response. When I console in and check pwd I get a simple / which tells me this is the root. and when I list the directory I see the images directory. So I'm not certain how to point to it. Could you point me to a guide or reference to properly setup my container for this script. I don't expect anyone to do the work for me but I could certainly use a nudge. Thanks. Edit: even with / in front of my images directly (in python script) it does not resolve the issue. Edited January 7, 2020 by HH0718 Supplemental information. Quote Link to comment
primeval_god Posted January 8, 2020 Share Posted January 8, 2020 You might try placing a file (with a recognizable name) in /mnt/user/BH/ on unRAID and then exec into you container and confirm it is where you expect it to be (search for it if neccissary). That way you can confirm that your mounts are setup the correct way. Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.