fluentd-docker-image icon indicating copy to clipboard operation
fluentd-docker-image copied to clipboard

Customized dockerfile cannot work

Open hsinhoyeh opened this issue 8 years ago • 11 comments

Hi,

I am creating a customized dockerfile for installing plugins like elasticsearch here is my dockerfile

FROM fluent/fluentd:ubuntu-base

USER ubuntu
WORKDIR /home/ubuntu
ENV PATH /home/ubuntu/.gem/ruby/2.2.0/bin:$PATH

# install plugins
RUN gem install fluent-plugin-secure-forward && \
    gem install fluent-plugin-elasticsearch

EXPOSE 24224

CMD fluentd -c /fluentd/etc/$FLUENTD_CONF -p /fluentd/plugins $FLUENTD_OPT

However, this dockerfile cannot work for me. there is no data in /fluentd/logs/*

ubuntu@3527aba5df6d:~$ ls -al /fluentd/log/*
ls: cannot access /fluentd/log/*: No such file or directory

but if I modify base dockerfile directly (by just adding gem install commands and REMOVE onbuild commands), it works.

FROM ubuntu:14.04
MAINTAINER TAGOMORI Satoshi <[email protected]>
LABEL Description="Fluentd docker image" Vendor="Fluent Organization" Version="1.0"

RUN apt-get update -y && apt-get install -y \
              autoconf \
              bison \
              build-essential \
              curl \      
              git \
              libffi-dev \              
              libgdbm3 \
              libgdbm-dev \
              libncurses5-dev \
              libreadline6-dev \              
              libssl-dev \
              libyaml-dev \
              zlib1g-dev \              
        && rm -rf /var/lib/apt/lists/*

RUN useradd ubuntu -d /home/ubuntu -m -U
RUN chown -R ubuntu:ubuntu /home/ubuntu

# for log storage (maybe shared with host)
RUN mkdir -p /fluentd/log
# configuration/plugins path (default: copied from .)
RUN mkdir -p /fluentd/etc
RUN mkdir -p /fluentd/plugins

RUN chown -R ubuntu:ubuntu /fluentd

USER ubuntu
WORKDIR /home/ubuntu

RUN git clone https://github.com/tagomoris/xbuild.git /home/ubuntu/.xbuild
RUN /home/ubuntu/.xbuild/ruby-install 2.2.2 /home/ubuntu/ruby

ENV PATH /home/ubuntu/ruby/bin:$PATH
RUN gem install fluentd -v 0.12.19

# install plugins
RUN gem install fluent-plugin-secure-forward && \
    gem install fluent-plugin-elasticsearch

COPY fluent.conf /fluentd/etc/
#######ONBUILD COPY fluent.conf /fluentd/etc/
#######ONBUILD COPY plugins /fluentd/plugins/

WORKDIR /home/ubuntu

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

EXPOSE 24224

### docker run -p 24224 -v `pwd`/log: -v `pwd`/log:/home/ubuntu/log fluent/fluentd:latest
CMD exec fluentd -c /fluentd/etc/$FLUENTD_CONF -p /fluentd/plugins $FLUENTD_OPT

seems we have an issue on ONBUILD commands.

hsinhoyeh avatar Apr 12 '16 02:04 hsinhoyeh

indeed on a tagged version like v0.12.21 there shouldn't be any onbuild command i'd say you should create an "onbuild" branch where you have the onbuild commands and release separate tags for onbuild versions, like "v0.12.21-onbuild"

i think that's the way the official images are built, like https://hub.docker.com/_/maven/ for instance

mazerty avatar Apr 17 '16 18:04 mazerty

@tagomoris How about this approach? > separate tags

repeatedly avatar Apr 20 '16 05:04 repeatedly

This official document also says so. Sounds good to do it. https://docs.docker.com/engine/userguide/eng-image/dockerfile_best-practices/#onbuild

tagomoris avatar Apr 20 '16 05:04 tagomoris

i have this and it works

FROM fluent/fluentd:v0.12.21

USER fluent
WORKDIR /home/fluent

ENV PATH /home/fluent/.gem/ruby/2.2.0/bin:$PATH
RUN gem install fluent-plugin-secure-forward && \
    gem install fluent-plugin-elasticsearch

EXPOSE 24284

CMD fluentd -c /fluentd/etc/$FLUENTD_CONF -p /fluentd/plugins $FLUENTD_OPT

arthurtsang avatar Apr 24 '16 04:04 arthurtsang

hi ! any news on this issue ?

mazerty avatar May 19 '16 11:05 mazerty

please have a look at my fork : https://github.com/mazerty/fluentd-docker-image since i can't create a pull request to create a new branch upstream this is what my fork do :

  1. create a new branch named "onbuild" from the last commit on master
  2. create a new tag on this branch with the name v0.12.25-onbuild
  3. remove the "onbuild" commands in the Dockerfile on master
  4. create a new tag on master with the name v0.12.25

that should do the trick, and now we can extend the base image without problem thanks !

mazerty avatar Jun 02 '16 10:06 mazerty

@mazerty Could you send a PR to compare the diff?

repeatedly avatar Jun 04 '16 22:06 repeatedly

done you'll have to create the onbuild branch and the two tags yourself though, it seems it can't be done through a pull request

mazerty avatar Jun 05 '16 11:06 mazerty

I just released two tags for normal and onbuild: https://hub.docker.com/r/fluent/fluentd/tags/

repeatedly avatar Jun 13 '16 21:06 repeatedly

these changes completely break any current downstream containers.

i have "children" containers based on docker tag 0.12.21, and am unable to simply upgrade them to 0.12.26 because of these changes...

i wish this was rolled into the upgrade to 0.14.0 (with a version change) and in upgrade notes...so the interface would stay the same...

stensonb avatar Jun 17 '16 23:06 stensonb

Hmm... simply changed to v0.12.26-onbuild has a problem?

repeatedly avatar Jun 18 '16 02:06 repeatedly