我一直在尝试外部化在 docker 容器中运行的 kibana 日志,但没有成功。我的docker compose如下:
kibana:
image: kibana:latest
container_name: kib
ports:
- "5601:5601"
links:
- elasticsearch
volumes:
- /var/log:/var/log
还有 Kibana.yml -logging.dest=/var/log/kibana.log
但是,当我运行它时,我在容器中收到如下错误:
events.js:85
throw er; // Unhandled 'error' event
^
Error: EACCES, open '/var/log/kibana.log'
at Error (native)
这看起来像是一个权限问题(仅供引用,我在 Ubuntu 上运行它)。我将主机上文件夹的权限设置为 7777。有什么想法吗?谢谢
最佳答案
kibana 进程运行为 kibana user (defined in the Dockerfile)由ENTRYPOINT "/docker-entrypoint.sh"
script .
如本文所示 similar issue
The dockerfile creates a user named sinopia and runs everything as that.
In general this is good practice, however, when accessing the host file system docker uses the same uid on the host as is used on the container. Root in container has root access on host, and user sinopia with id 1000 in container is mapped to user 1000 on host.If you create a user on the host with id 1000 you can then grant this user permissions to the host directory as desired.
检查 Dockerfile 创建的用户 sinatra 的 ID,并查看您是否可以在主机上授予对同一 ID 的访问权限。
如果您chmod +777
,请重试docker-compose up
。 (这是为其他 docker images like libreboard
完成的)
OP sharman解释in the comments为什么 chmod 777 无效:
Yes I had the user created (so that I could run docker without sudo) and was UID 1000 GID 1000.
However my volume mapping was incorrect - I have mapped the volume to a non existent folder on kibana and config file was point to this one.
关于logging - Dockerized Kibana 外部化日志,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34804179/