CMD ["supervisord"、“-c”、“/etc/supervisor.conf”] 和 USER 非 root 中的错误
Error in CMD ["supervisord", "-c", "/etc/supervisor.conf"] and USER non-root
我需要运行 docker container always non-root user also under supervisor.conf all services need to up status 但仍然出现以下错误
回溯(最后一次调用):
文件“/usr/bin/supervisord”,第 11 行,位于
load_entry_point('supervisor==4.1.0', 'console_scripts', 'supervisord')()
主文件“/usr/lib/python3/dist-packages/supervisor/supervisord.py”,第 358 行
去(选项)
文件“/usr/lib/python3/dist-packages/supervisor/supervisord.py”,第 368 行,在 go 中
d.main()
主文件“/usr/lib/python3/dist-packages/supervisor/supervisord.py”,第 70 行
self.options.make_logger()
文件“/usr/lib/python3/dist-packages/supervisor/options.py”,第 1466 行,在 make_logger 中
loggers.handle_file(
文件“/usr/lib/python3/dist-packages/supervisor/loggers.py”,第 417 行,在 handle_file 中
handler = RotatingFileHandler(文件名, 'a', maxbytes, 备份)
init 中的文件“/usr/lib/python3/dist-packages/supervisor/loggers.py”,第 213 行
FileHandler.init(self, filename, mode)
init 中的文件“/usr/lib/python3/dist-packages/supervisor/loggers.py”,第 160 行
self.stream = 打开(文件名,模式)
PermissionError:[Errno 13] 权限被拒绝:'/supervisord.log'
我的要求是必须以非 root 用户身份登录容器,并且在 docker 运行 之后 运行 将 supervisor.conf 中的所有服务。我只需要非 root 用户普通用户并且没有任何类型的访问权限。
Dockerfile 最后 3 行
运行 useradd -m nonroot && echo "nonroot:nonroot123" |密码
USER 非 root
CMD ["supervisord", "-c", "/etc/supervisor.conf"]
错误表明您的supervisord 运行作为非特权用户不允许写入直接在/
下的文件 -> /supervisord.log
根据 supervisord documentation,日志路径默认为当前工作目录中的 supervisord.log
,可通过以下方式配置:
the logfile parameter in the [supervisord] section of the configuration file, defaulting to $CWD/supervisord.log.
这里有两个选择:
- 使用
WORKDIR
Dockerfile 命令将容器的默认工作目录更改为您的非根用户拥有完全权限的路径。无论如何你都应该这样做,因为你是 运行 非特权用户
- 编辑
/etc/supervisor.conf
,设置日志的可写路径
我需要运行 docker container always non-root user also under supervisor.conf all services need to up status 但仍然出现以下错误
回溯(最后一次调用): 文件“/usr/bin/supervisord”,第 11 行,位于 load_entry_point('supervisor==4.1.0', 'console_scripts', 'supervisord')() 主文件“/usr/lib/python3/dist-packages/supervisor/supervisord.py”,第 358 行 去(选项) 文件“/usr/lib/python3/dist-packages/supervisor/supervisord.py”,第 368 行,在 go 中 d.main() 主文件“/usr/lib/python3/dist-packages/supervisor/supervisord.py”,第 70 行 self.options.make_logger() 文件“/usr/lib/python3/dist-packages/supervisor/options.py”,第 1466 行,在 make_logger 中 loggers.handle_file( 文件“/usr/lib/python3/dist-packages/supervisor/loggers.py”,第 417 行,在 handle_file 中 handler = RotatingFileHandler(文件名, 'a', maxbytes, 备份) init 中的文件“/usr/lib/python3/dist-packages/supervisor/loggers.py”,第 213 行 FileHandler.init(self, filename, mode) init 中的文件“/usr/lib/python3/dist-packages/supervisor/loggers.py”,第 160 行 self.stream = 打开(文件名,模式) PermissionError:[Errno 13] 权限被拒绝:'/supervisord.log'
我的要求是必须以非 root 用户身份登录容器,并且在 docker 运行 之后 运行 将 supervisor.conf 中的所有服务。我只需要非 root 用户普通用户并且没有任何类型的访问权限。
Dockerfile 最后 3 行
运行 useradd -m nonroot && echo "nonroot:nonroot123" |密码
USER 非 root
CMD ["supervisord", "-c", "/etc/supervisor.conf"]
错误表明您的supervisord 运行作为非特权用户不允许写入直接在/
下的文件 -> /supervisord.log
根据 supervisord documentation,日志路径默认为当前工作目录中的 supervisord.log
,可通过以下方式配置:
the logfile parameter in the [supervisord] section of the configuration file, defaulting to $CWD/supervisord.log.
这里有两个选择:
- 使用
WORKDIR
Dockerfile 命令将容器的默认工作目录更改为您的非根用户拥有完全权限的路径。无论如何你都应该这样做,因为你是 运行 非特权用户 - 编辑
/etc/supervisor.conf
,设置日志的可写路径