Skip to content
View in the app

A better way to browse. Learn more.

Unraid

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

How to create custom docker image with persistent storage on unraid?

Featured Replies

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.

 

 

unraid_mount.PNG.6b56dc8f143c10404d8adcfa2d72a6dc.PNG

 

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 by stig
adding more info

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 by primeval_god

  • Author
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?

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.

  • Author
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?

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.

Guest
Reply to this topic...

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.