logging - Dockerized Kibana 外部化日志

标签 logging docker kibana

我一直在尝试外部化在 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/

相关文章:

docker - 分配 docker 问题

visual-studio - Docker Desktop for Windows 使用 Linux 容器 - 运行容器时出现权限错误

java - 当程序登录到控制台时会发生什么?

python - 使用正则表达式读取日志

mysql - docker mysql-container 卷映射到项目中的文件夹 - 安全吗?

elasticsearch - 无法将Marvel安装到Kibana中

logging - 使用 fluidd 解析数据

.net - Serilog Elasticsearch 日志未发送到服务器(但缓冲正确)

logging - 在多台机器上搜索日志

java - 是否可以使用 Log4J 仅记录一级消息