mirror of
https://github.com/motioneye-project/motioneye.git
synced 2026-03-02 22:57:06 -05:00
Running motioneye docker as non-root user, can't access /var/run #2247
Labels
No labels
Android app
Arch Linux
CI/CD
CSS
FreeBSD
HTML/HTTP
Home Assistant addon
JavaScript
Python
Raspberry Pi
Stale No Activity 60 Days
bug
code format
dependencies
dev branch
docker
documentation
duplicate
enhancement
feature
help wanted
i18n/l10n
invalid
legacy motionEye
meta
motion
motionEyeOS
notourproblem
python update
question
question
security
troubleshooting
wontfix
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/motioneye#2247
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @towerofpower256 on GitHub (Jun 21, 2022).
If I installed the motioneye docker and ran as root, no issues there.
However I run into an issue when I use the motioneye docker image as another user that is not root (e.g.
--user 1003:1003). I started getting errors that are visible in the log saying that motioneye was unable to create the .pid file in the /var/run directory. Motioneye isn't able to start either, and I can't get to the web interface.The log:
Here's my docker run command, including
--userand RUN_UID and RUN_GID arguments:I was able to get around this by updating motioneye.conf to store the pid file in another directory that motioneye should have access to. This fix appears to be working so far.
I suspect this is due to the Docker image that the motioneye docker image is utilizing,
debian:buster-slim.github.com/debuerreotype/docker-debian-artifacts@337f494fae/buster/slim/rootfs.tar.xzDoing some poking around:
/runexists, with permissions of 755 (writable by root, read-only to everything else)./var/runexists appears to be a link to/run.Console output:
In the motioneye docker file, I can see that it's trying to own the
/var/runfolder, but I believe it's only chowning the link to the/rundirectory, not the/rundirectory itself, which is causing the issue.Does that mean the fix is just to update the docker file to include
/runin the directories that it's chowning?@towerofpower256 commented on GitHub (Jun 21, 2022):
Possibly related to:
#2407
#2388
@towerofpower256 commented on GitHub (Jun 21, 2022):
This article here suggests that it may be better to create a directory within
runto hold app-specific pid files.https://serverfault.com/questions/159334/what-permissions-are-needed-to-write-a-pid-file-in-var-run
E.g. a new directory
/var/run/motioneye, grant full access for themotionuser to that directory, and update the motioneye.conf to store the pid files in there, instead of just/var/run.@tobschndr commented on GitHub (Nov 8, 2022):
I am facing the same issues.
Via Portainer the log is showing the following after reboot (as assumed with regard to the article):
INFO: hello! this is motionEye server 0.42.1
CRITICAL: pid directory "/var/run/motioneye" does not exist or is not writable
So I wrote a startup script as linked in the article:
(thanks @towerofpower256 )
mkdir /var/run/motioneye
chown motioneye:motioneye /var/run/motioneye
My questions:
@PhatHub commented on GitHub (Feb 20, 2023):
For those who haven't figured out the systemd-onic (sorry didn't know how to say "systemd" in the same way of "pythonic") way of doing it, I just found out... utilize
tmpfiles.dIt took me a while because the first time I tried to google for the answer, it took me weeks, and I couldn't find anything besides "it'll be complex."
A few weeks later I found this answer within minutes, and it all clicked.
I did this on Ubuntu Server, so YMMV if you're on something else, like RedHat.
tmpfiles.dis an installable package, so if it doesn't work, make sure it's installed but I doubt it'll be missing since basically everyone is runningsystemd.sudo touch /usr/lib/tmpfiles.d/motioneye.confsudo vim /usr/lib/tmpfiles.d/motioneye.com(or use your preferred editor instead ofvim)d /var/run/motioneye 0744 motion motion(I put tabs instead of spaces to kind of line up columns in the future)systemctl stop motioneyeto force it to delete the previous pid directory.systemctl start motioneyeHopefully this helps.
@MichaIng commented on GitHub (Mar 30, 2023):
@PhatHub
It's about the Docker image here, which has no systemd or native tmpfiles support.
Best solution is to allow not having any PID file at all. It is nonsense in this Docker image but currently not possible. I'll see if I find time to implement this during the weekend. But otherwise using
/etc/motioneyeindeed is a good idea and shouldn't cause any issues.