Home > Software engineering >  Error in CMD ["supervisord", "-c", "/etc/supervisor.conf"] and USER no
Error in CMD ["supervisord", "-c", "/etc/supervisor.conf"] and USER no

Time:12-24

I need to run docker container always non-root user also under the supervisor.conf all services need to up status but still getting following error

Traceback (most recent call last): File "/usr/bin/supervisord", line 11, in load_entry_point('supervisor==4.1.0', 'console_scripts', 'supervisord')() File "/usr/lib/python3/dist-packages/supervisor/supervisord.py", line 358, in main go(options) File "/usr/lib/python3/dist-packages/supervisor/supervisord.py", line 368, in go d.main() File "/usr/lib/python3/dist-packages/supervisor/supervisord.py", line 70, in main self.options.make_logger() File "/usr/lib/python3/dist-packages/supervisor/options.py", line 1466, in make_logger loggers.handle_file( File "/usr/lib/python3/dist-packages/supervisor/loggers.py", line 417, in handle_file handler = RotatingFileHandler(filename, 'a', maxbytes, backups) File "/usr/lib/python3/dist-packages/supervisor/loggers.py", line 213, in init FileHandler.init(self, filename, mode) File "/usr/lib/python3/dist-packages/supervisor/loggers.py", line 160, in init self.stream = open(filename, mode) PermissionError: [Errno 13] Permission denied: '/supervisord.log'

My requirement is must login container as a non root user and after docker run will be running all service in supervisor.conf. I need non root user only normal user and don't have any type of access.

Dockerfile last 3 line

RUN useradd -m nonroot && echo "nonroot:nonroot123" | chpasswd

USER nonroot

CMD ["supervisord", "-c", "/etc/supervisor.conf"]

CodePudding user response:

The error shows that your supervisord running as a non-privileged user is not allowed to write to a file directly under / -> /supervisord.log

As per the supervisord documentation, the log path defaults to supervisord.log in the current working directory, and is configurable via:

the logfile parameter in the [supervisord] section of the configuration file, defaulting to $CWD/supervisord.log.

You have two options here:

  • Change the container's default working directory to a path where your non-root user has full permissions, using the WORKDIR Dockerfile command. You should probably do this anyway as you're running it with a non-privileged user
  • Edit /etc/supervisor.conf, setting a writable path for the log
  • Related