Skip to content

Commit

Permalink
fix: telegraf do not run as root
Browse files Browse the repository at this point in the history
This runs Telegraf as a non-root user. For the Debian based Dockerfiles,
the deb package will create a telegraf user and group for usage. All
that is needed is to say run as the telegraf user.

For Alpine based images, a telegraf user and group needs to be created
and then run as that telegraf user.

Fixes: #412
  • Loading branch information
powersj committed Oct 13, 2021
1 parent 4a53965 commit 8352018
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 0 deletions.
2 changes: 2 additions & 0 deletions telegraf/1.18/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ RUN ARCH= && dpkgArch="$(dpkg --print-architecture)" && \

EXPOSE 8125/udp 8092/udp 8094

USER telegraf

COPY entrypoint.sh /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]
CMD ["telegraf"]
4 changes: 4 additions & 0 deletions telegraf/1.18/alpine/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ RUN set -ex && \

EXPOSE 8125/udp 8092/udp 8094

RUN addgroup -S telegraf
RUN adduser -S telegraf -G telegraf
USER telegraf

COPY entrypoint.sh /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]
CMD ["telegraf"]
2 changes: 2 additions & 0 deletions telegraf/1.19/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ RUN ARCH= && dpkgArch="$(dpkg --print-architecture)" && \

EXPOSE 8125/udp 8092/udp 8094

USER telegraf

COPY entrypoint.sh /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]
CMD ["telegraf"]
4 changes: 4 additions & 0 deletions telegraf/1.19/alpine/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ RUN set -ex && \

EXPOSE 8125/udp 8092/udp 8094

RUN addgroup -S telegraf
RUN adduser -S telegraf -G telegraf
USER telegraf

COPY entrypoint.sh /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]
CMD ["telegraf"]
2 changes: 2 additions & 0 deletions telegraf/1.20/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ RUN ARCH= && dpkgArch="$(dpkg --print-architecture)" && \

EXPOSE 8125/udp 8092/udp 8094

USER telegraf

COPY entrypoint.sh /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]
CMD ["telegraf"]
4 changes: 4 additions & 0 deletions telegraf/1.20/alpine/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ RUN set -ex && \

EXPOSE 8125/udp 8092/udp 8094

RUN addgroup -S telegraf
RUN adduser -S telegraf -G telegraf
USER telegraf

COPY entrypoint.sh /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]
CMD ["telegraf"]

0 comments on commit 8352018

Please sign in to comment.