Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Permissions error while running fluentd with non-root user #420

@prashantcsutar

Description

@prashantcsutar

I created a customized image for my project.

Dockerfile:


FROM fluent/fluentd:v1.4.2-debian-2.0

USER root

WORKDIR /home/fluent
ENV PATH /fluentd/vendor/bundle/ruby/2.6.0/bin:$PATH
ENV GEM_PATH /fluentd/vendor/bundle/ruby/2.6.0
ENV GEM_HOME /fluentd/vendor/bundle/ruby/2.6.0

ENV FLUENTD_DISABLE_BUNDLER_INJECTION 1

COPY Gemfile* /fluentd/
RUN buildDeps="sudo make gcc g++ libc-dev libffi-dev"
&& apt-get update
&& apt-get upgrade -y
&& apt-get install
-y --no-install-recommends
$buildDeps net-tools
&& gem install bundler --version 1.16.2
&& bundle config silence_root_warning true
&& bundle install --gemfile=/fluentd/Gemfile --path=/fluentd/vendor/bundle
&& SUDO_FORCE_REMOVE=yes
apt-get purge -y --auto-remove
-o APT::AutoRemove::RecommendsImportant=false
$buildDeps
&& rm -rf /var/lib/apt/lists/*
&& gem sources --clear-all
&& rm -rf /tmp/* /var/tmp/* /usr/lib/ruby/gems//cache/.gem

COPY ./conf/fluent.conf /fluentd/etc/
COPY ./conf/systemd.conf /fluentd/etc/
COPY ./conf/kubernetes.conf /fluentd/etc/
COPY ./conf/prometheus.conf /fluentd/etc/
RUN touch /fluentd/etc/disable.conf

COPY plugins /fluentd/plugins/
COPY entrypoint.sh /fluentd/entrypoint.sh

ENV FLUENTD_OPT=""
ENV FLUENTD_CONF="fluent.conf"

RUN chmod -R 666 /var/log/
RUN chown -R fluent:fluent /var/log/
RUN chmod -R 777 /fluentd/
RUN chown -R fluent:fluent /fluentd/
RUN chmod -R 777 /home/fluent
RUN chown -R fluent:fluent /home/fluent

USER fluent
ENTRYPOINT ["tini", "--", "/fluentd/entrypoint.sh"]
CMD ["fluentd"]


But getting below error in fluentd pod.
Permission denied @ rb_sysopen - /var/log/containers.pos

Solutions tried so far:

  1. Init containers to change permissions of /var/log. But new log files are getting added with root user.
  2. Creating pos file inside pod at location /home/fluent/containers.pos but in this approach log files are not readable.

Please help!

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions