这是流畅的 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/