Logging to stdout as an unprivileged user gets "permission denied"

I’ve been maintaining my own Docker image to run Caddy with Hugo, and I originally based the Dockerfile on abiosoft’s excellent example. I recently noticed that he modified it to run as an unprivileged user, so I included that functionality in my own.

Since I’m running Caddy in Docker, it made sense to me to log directly to stdout with log stdout, but when I start everything up, I get:

2016/09/08 17:10:28 open log: permission denied

What’s odd is that I can run it with a shell (--entrypoint=/bin/sh), and this works just fine:

echo OUT >/dev/stdout OUT

Here’s my repo, which includes the Dockerfile and the example Caddyfile config:

You are telling Caddy to log errors to a file called log.

Yes I am, doh! I guess I never noticed it since previously it was running as root and had full access to the root directory. Changed the directive to:
errors stdout
And everything worked magically. Thanks!

1 Like

Great :slight_smile: Glad it’s working now!

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.