docker日志挂载的问题
程序员文章站
2022-05-15 13:13:54
...
关键是本地服务器没有写入的权限
关键看这里吧(Permission denied), 一直没有看正方,以为是配置日志文件 找不到有问题,下面是部分异常
10:35:09,498 |-ERROR in ch.qos.logback.core.rolling.RollingFileAppender[FILE] - openFile(null,true) call failed. java.io.FileNotFoundException: logs/bandwidth.log.2019-04-25.log (Permission denied)
at java.io.FileNotFoundException: logs/bandwidth.log.2019-04-25.log (Permission denied)
at at java.io.FileOutputStream.open0(Native Method)
at at java.io.FileOutputStream.open(FileOutputStream.java:270)
at at java.io.FileOutputStream.<init>(FileOutputStream.java:213)
at at ch.qos.logback.core.recovery.ResilientFileOutputStream.<init>(ResilientFileOutputStream.java:26)
at at ch.qos.logback.core.FileAppender.openFile(FileAppender.java:204)
at at ch.qos.logback.core.FileAppender.start(FileAppender.java:127)
at at ch.qos.logback.core.rolling.RollingFileAppender.start(RollingFileAppender.java:100)
at at ch.qos.logback.core.joran.action.AppenderAction.end(AppenderAction.java:90)
at at ch.qos.logback.core.joran.spi.Interpreter.callEndAction(Interpreter.java:309)
at at ch.qos.logback.core.joran.spi.Interpreter.endElement(Interpreter.java:193)
尝试好多遍,才真正看懂原因也是从网上看到的一点启发,希望大家也能注意到,我用如下命令完美解决
docker run -it --privileged=true -v /dockerlogs:/app/logs -d -p 5080:5080 82edb4bbc79b
挂载宿主机已存在目录后,在容器内对其进行操作,报“Permission denied”
可通过两种方式解决:
1> 关闭selinux。
临时关闭:# setenforce 0
永久关闭:修改/etc/sysconfig/selinux文件,将SELINUX的值设置为disabled。
2> 以特权方式启动容器
指定--privileged参数
如:# docker run -it --privileged=true -v /test:/softlogs