docker - 以非根身份运行 Fluentd Docker 镜像

标签 docker root fluentd

这是流畅的 Docker 镜像:https://github.com/fluent/fluentd-docker-image

下面是 Dockerfile:

FROM fluent/fluentd:onbuild

USER root

# below RUN includes two plugins as examples
# elasticsearch and record-reformer are not required
# you may customize including plugins as you wish

RUN apk add --update --virtual .build-deps \
        sudo build-base ruby-dev \
 && sudo -u fluent gem install \
        fluent-plugin-elasticsearch \
        fluent-plugin-record-reformer \
 && sudo -u fluent gem sources --clear-all \
 && apk del .build-deps \
 && rm -rf /var/cache/apk/* \
           /home/fluent/.gem/ruby/2.3.0/cache/*.gem

USER fluent

EXPOSE 24284

将其作为 docker 镜像运行后

docker exec -it b3c565091160 /bin/sh

cat /etc/passwd

fluent:x:1000:1000::/home/fluent:

/home/fluent # ps -ef
PID   USER     TIME   COMMAND
    1 root       0:00 {fluentd} /usr/bin/ruby /usr/bin/fluentd -c /fluentd/etc/fluent.conf -p /fluentd/plugins
    8 root       0:12 {fluentd} /usr/bin/ruby /usr/bin/fluentd -c /fluentd/etc/fluent.conf -p /fluentd/plugins
   22 root       0:00 /bin/sh
   28 root       0:00 ps -ef
/home/fluent # whoami
root

如何以流畅的用户身份运行此 Fluentd,特别是用户 1000 而不是 ROOT?

最佳答案

你必须在 entrypoint.sh 中修改它 fluentd 有一个二进制启动命令,就像容器中的每个应用程序一样。 这个应用程序主要是从 entrypoint.sh 启动的

在这里我没有看到 entrypoint.sh 或应用程序 fluentd 的启动位置? 启动此应用程序时,会设置应用程序运行时使用的 ID。

关于docker - 以非根身份运行 Fluentd Docker 镜像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43940614/

相关文章:

python - 在AWS EKS中打印/返回python应用程序docker图像输出而不使用flask

docker - 如何在$之前更改命令提示 rune 本的字体颜色

docker - 访问 Docker For Desktop 中本地运行的 Kubernetes 服务?

html - 在 ReactJS 上,我的 'root' div 并没有一直向上延伸。我怎样才能扩大它?

jquery - 如何使用 jQuery 找到根 div?

config - Fluentd 配置文件,在 <source> 中获取文件名并将其作为标记传递给 <match>

elasticsearch - Fluentd似乎正在工作,但是在Kibana中没有日志

php - 如何修复 Docker 上的 'Failed to fetch Debian Jessie-updates' 问题?

python - linux 目录权限检查和/或 dir 是否存在

replace - 如何用fluentd中的特定字符串替换键值字符串