stig Posted April 3, 2023 Share Posted April 3, 2023 (edited) Hello, I am trying to do something very simple, but I lack some knowledge on docker. I have a docker image in a private GitHub repo that updates the image on dockerhub when pushed. Docker file FROM python:alpine3.17 WORKDIR /apps COPY . . CMD [ "python", "app.py" ] Python file import time print("Hello unraid docker, just testing first setup") time.sleep(30) Simple, nothing crazy. Now since I got it working on unraid I wanted to figure out how to add storage to my appdata share like other containers from the community apps do. To start, first I tried to see if I could just make a path from the container to host to at least see if files would show up from the container. I've had to add/change container paths before on community apps to get to different files with no issues. The folder in the share comes up and... It's empty... but the apps folder on the container is there with the files added. So I tried other container paths, but nothing, or the container would crash with an exec error. I realize I am missing something. Am I adding the wrong path, or do need to specify a volume in my dockerfile? In other dockerfiles I never see a volume added so I am at a loss. Additionally, how does one give access to the base appdata folder to a docker container so you can monitor files? I've tried using inotify but it didn't have the functionality I was looking for. Edited April 3, 2023 by stig adding more info Quote Link to comment
primeval_god Posted April 4, 2023 Share Posted April 4, 2023 (edited) Bind mounting gives the docker container access to a folder from the host not the other way around. When you mount the host path /mnt/user/appdata/unraid_testing/ to /apps in the container you are mounting unraid_testing over the apps folder essentially hiding the existing folder in the container. If unraid_testing had files in it they would be accessible inside the container and if something in the container where then to place a file in /apps it would be accessible from the host unraid_testing folder. Edited April 4, 2023 by primeval_god Quote Link to comment
stig Posted April 6, 2023 Author Share Posted April 6, 2023 On 4/4/2023 at 10:46 AM, primeval_god said: Bind mounting gives the docker container access to a folder from the host not the other way around. When you mount the host path /mnt/user/appdata/unraid_testing/ to /apps in the container you are mounting unraid_testing over the apps folder essentially hiding the existing folder in the container. If unraid_testing had files in it they would be accessible inside the container and if something in the container where then to place a file in /apps it would be accessible from the host unraid_testing folder. Okay I think I understand this. I ran a couple more tests and see what you are saying, but how would I modify my dockerfile to have the files already in it when I set the bind mount? Do I need to add a volume and then copy the files over or do something in the CMD script? Quote Link to comment
primeval_god Posted April 6, 2023 Share Posted April 6, 2023 11 hours ago, stig said: Okay I think I understand this. I ran a couple more tests and see what you are saying, but how would I modify my dockerfile to have the files already in it when I set the bind mount? Do I need to add a volume and then copy the files over or do something in the CMD script? If you want to put files into the bind mount directory it has to be done at runtime. You would need to put the files somewhere else in the image, then have a script that runs when the container starts to copy them to the bind mount directory if they are not already there. Quote Link to comment
stig Posted April 7, 2023 Author Share Posted April 7, 2023 On 4/6/2023 at 10:20 AM, primeval_god said: If you want to put files into the bind mount directory it has to be done at runtime. You would need to put the files somewhere else in the image, then have a script that runs when the container starts to copy them to the bind mount directory if they are not already there. Okay I will try this. Is this usually how other community docker apps do this for accessing files? 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.