知识库

Docker “权限被拒绝”错误

当启动 Docker 实例时,可能会出现类似的权限被拒绝错误,例如

2018-06-14 23:20:50.962+0000 ERROR Failed to start Neo4j: Starting Neo4j failed: Component 'org.neo4j.server.database.LifecycleManagingDatabase@7880cdf3' was successfully initialized, but failed to start. Please see the attached cause exception "/logs/debug.log (Permission denied)". Starting Neo4j failed: Component 'org.neo4j.server.database.LifecycleManagingDatabase@7880cdf3' was successfully initialized, but failed to start. Please see the attached cause exception "/logs/debug.log (Permission denied)".

并可能导致启动失败。

Docker 过去是以 root 身份运行的,但现在已经改为非 root 运行。此更改在 3.1.8、3.2.9、3.3.4 Docker 镜像以及 3.4 及以后版本中引入。为了让任何新版 Neo4j 继续访问这些旧版 logsconfdata,必须修改旧版本创建的文件权限——尤其是已有的日志文件和数据文件。

为 “everyone” 授予 logs 目录的访问权限可以规避 “权限被拒绝” 错误,但这不是首选方案。我们的建议是以下两种方式之一:

A) 将传递给 Docker 的用户设置为 logs 目录的所有者或其主要组,并赋予读写权限。如何将 --user 作为参数传递给 Docker,可参见以下知识库文章。https://support.neo4j.com/hc/en-us/articles/360012923574-Running-Docker-as-Non-Root-User

或者

B) 创建一个对 logs 目录有访问权限的次要组,例如 sudo groupadd logs,并将运行 Neo4j 的用户加入该组。如果采用此方法,需要在 Docker 中使用 --group-add 标志额外传入该次要组。例如

group-add="$(getent group logs | cut -d ":" -f3)"
© . This site is unofficial and not affiliated with Neo4j, Inc.