I'm trying to start a docker container, which has 2 services. One of those services needs to be run as a non-root User, otherwise he won't start. The other must run as root.

Now I want to link the non_root_service.log file to either /dev/tty or /dev/stdout, so that the logs could be catched by docker (check with docker logs $CONTAINER):

ln -s /dev/stdout non_root_service.log

The Problem is by doing so, that the non-root User has no rights to write to either /dev/tty or /dev/stdout resulting in the following error on startup of the non-root-service:

cannot open "non_root_service.log": Permission denied

But if I don't create the link, I could not catch the logs with docker logs $CONTAINER. Does anyone has an idea how that could be fixed, so that I could run the user as non-root AND link the log files to /dev/{tty,stdout}?

P.S.: Does not matter if I use as shell script CMD ["starter.sh"] or supervisor CMD ["supervisord", "-n", "-c", "/app/supervisord.conf"] to start the 2 services, I get with both the same error.


Maybe not the cleanest solution, but could you try this:

tail -f non_root_service.log &

To simply tail the file to stdout and background the tail process? You might also try tailing straight to the stdout p:

ln -s ln -fs /proc/self/fd/1 non_root_service.log

However, are you sure that you have rights to the non_root_service.log file? What do you see if you run stat non_root_service.log and whoami?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.