docker - Filebeat 无法作为 docker 容器启动

标签 docker ubuntu docker-compose filebeat

以下是使用的 docker-compose。

version: '3.5'
services:
  filebeat: 
    image: docker.elastic.co/beats/filebeat:6.4.2
    volumes:
      - ${PWD}/filebeat.yml:/usr/share/filebeat/filebeat.yml:ro
      - ${PWD}/test/input:/tmp/input:rw
filebeat.yml 中的 Filebeat 配置为
filebeat.inputs:
- type: container
  paths: 
    - '/var/lib/docker/containers/*/*.log'

processors:
- add_docker_metadata:
    host: "unix:///var/run/docker.sock"

- decode_json_fields:
    fields: ["message"]
    target: "json"
    overwrite_keys: true

output.elasticsearch:
  hosts: ["elasticsearch:9200"]
  indices:
    - index: "filebeat-%{[agent.version]}-%{+yyyy.MM.dd}"

logging.json: true
logging.metrics.enabled: false
根据 docker-compose up , 容器启动失败并报告以下错误。
退出:加载配置文件时出错:配置文件(“filebeat.yml”)必须由用户标识符(uid = 0)或root拥有
这里有什么问题?我正在运行 ubuntu 的笔记本电脑上运行此示例。

最佳答案

error loading config file: config file ("filebeat.yml") must be owned by the user identifier (uid=0) or root


通常,我们以 root 身份启动 filebeat(以确保它可以访问系统的所有文件)。
您可以尝试以 root 身份启动 compose 的 filebeat 服务:
version: '3.5'
services:
  filebeat: 
    user: root #change here
    image: docker.elastic.co/beats/filebeat:6.4.2
    volumes:
      - ${PWD}/filebeat.yml:/usr/share/filebeat/filebeat.yml:ro
      - ${PWD}/test/input:/tmp/input:rw
如果这还不够,您可以使用 -strict.perms=false 运行容器禁用权限检查的参数,例如:
version: '3.5'
services:
  filebeat: 
    user: root #change here
    image: docker.elastic.co/beats/filebeat:6.4.2
    command:
      - "-e"
      - "--strict.perms=false"
     ...
PS:-e flag 禁用 syslog/file 输出并重定向 std 错误中的所有输出(与您的观点无关,但通常在容器中需要从容器日志中读取 filebeat 日志)。
More info on the official site .

关于docker - Filebeat 无法作为 docker 容器启动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62960322/

相关文章:

docker - Gitlab 的 artifacts zip 文件是空的

linux - 打开后终端立即关闭

ubuntu - 如何在 Ubuntu 下对 init.d 脚本进行排序

docker - 如何将 "- u 0"选项传递到 docker compose 中?

mysql - 如何在数据库docker容器中创建数据库?

elasticsearch - 使用 elasticsearch 5.0 启动新容器时失败

macos - dockerized testcafe 远程浏览器测试

php - Docker - 如何在 docker-compose.yml 中设置 Apache + PHP

python - Docker - 超时值连接是超时

python - 安装 OpenCV,没有名为 cv2.cv 的模块