我有一个运行Java进程并在Dockerfile内的容器内声明的特定卷中写入Java日志的容器:
Dockerfile:
FROM myRegistry/jdk:1.8.181
VOLUME /opt/logs
ENTRYPOINT ["java",","/opt/application/myapp.jar", "--spring.profiles.active=server"]
如您所见,我正在容器中声明此卷/opt/logs
。
(在我的Java应用程序内部,该文件夹被logback用来写入错误)
但是运行容器时,它在几秒钟后失败,提示无法访问此文件夹"permission denied"
:
Caused by: java.lang.IllegalStateException: Logback configuration error detected:
ERROR in ch.qos.logback.core.rolling.RollingFileAppender[FILE] - openFile(/opt/logs/myapp.log,true) call failed. java.io.FileNotFoundException: /opt/logs/myapp.log (Permission denied)
at org.springframework.boot.logging.logback.LogbackLoggingSystem.loadConfiguration(LogbackLoggingSystem.java:153)
at org.springframework.boot.logging.AbstractLoggingSystem.initializeWithSpecificConfig(AbstractLoggingSystem.java:56)
at org.springframework.boot.logging.AbstractLoggingSystem.initialize(AbstractLoggingSystem.java:46)
at org.springframework.boot.logging.logback.LogbackLoggingSystem.initialize(LogbackLoggingSystem.java:106)
at org.springframework.boot.logging.LoggingApplicationListener.initializeSystem(LoggingApplicationListener.java:266)
... 18 more
我成功访问了该容器,然后才能查看权限:
[myuser@8d39ada92190 opt]$ ll
total 49100
-rwxrwxrwx. 1 myuser mygroup 50273298 Sep 19 15:57 myapp.jar
drwxr-xr-x 2 65534 65534 4096 Oct 1 13:52 logs
我注意到“ logs
”文件夹与普通用户和组(myuser / mygroup)无关,但与其他陌生目录 65534 < / p>
任何想法