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.

Need help building an interactive python docker container

Featured Replies

Hi everyone,

I've got a python app that can take a small variety of of launch parameters.

Currently I've built a docker image that works in Unraid, that will run it with default parameters, and output stuff to the log.

That's great, but what I'd love is to launch the image and just have it sit there.

Then you go into the console for it, and actually run the python program from there, with whatever launch parameters you want that time.

I'm sure this is a case of me not knowing much about docker/unraid yet and dabbling in things I don't fully understand.

dockerfile:

FROM python:3.11-alpine3.20

WORKDIR /

RUN apk update && apk add git (needed programs)

RUN adduser -D (username) && mkdir /config /data /app

RUN chown (username):(username)-R /config /data /app

USER (username)

ENV HOME=/config \

TZ=Etc/UTC \

HOSTNAME=(image name)

RUN pip install --upgrade pip

COPY /app/requirements.txt requirements.txt

RUN pip install --no-cache-dir -r requirements.txt

ENTRYPOINT ["/bin/sh", "-c"]

image run command:

docker run -it --name='ImageName' --net='bridge' --pids-limit 2048 -e TZ="America/New_York" -e HOST_OS="Unraid" -e HOST_HOSTNAME="Unraid" -e HOST_CONTAINERNAME="ImageName" -l net.unraid.docker.managed=dockerman -v '/mnt/user/appdata/omb/':'/config/.omb':'rw' -v '/mnt/user/omb/monitored':'/monitored':'rw' -v '/mnt/user/omb/app':'/app':'rw' -v '/mnt/user/omb/init':'/init':'rw' omb -c "bin/sh /init/init.sh"

init.sh:

cd /app

python -u omb # the -u switch makes all print statements go to the log, which we can see in Unraid

Is there a way to modify this to make it not actually fire off a script but just wait, so I can launch the Console for that docker and run it manually?

Edited by theothermatt_b

Solved by primeval_god

  • Solution

I am not sure you need to modify the image at all. I think you could just change the docker run command. Change the CMD portion of the docker run command to something like sleep infinity

and change the -it flag to -d to run the container in detached mode.

Edited by primeval_god

  • Author

That didn't end up being the fix I used, but you pushed me in the right direction (a lot of times its just like, i don't even know what to search for).

I ended up changing -it to -d -t and removing anything after the image name at all.

Also I removed the ENTRYPOINT line entirely from the dockerfile

Thank you!! (Assuming none of the above was a stupid thing to do for any reason...)

The only trick left is if I could have the console default to the /app directory instead of /

Add another WORKDIR line at the end of the dockerfile. Or use the --workdir option in your run command

Edited by primeval_god

  • Author

That nailed it. Thank you SO MUCH!

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.