Skip to content

Commit

Permalink
Introduce tini as init system for Docker containers (#22137) (#22982)
Browse files Browse the repository at this point in the history
Introduce tini as init system for Docker containers. Tini is the init system
used in docker images of other Elastic products.
It implements basic init functionality as reaping zombie processes and
properly handle signals.

(cherry picked from commit ee50020)

Co-authored-by: Przemysław Hejman <przemyslaw.hejman@elastic.co>
  • Loading branch information
jsoriano and mieciu authored Dec 8, 2020
1 parent 5812c1b commit 863aec4
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.next.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,7 @@ https://github.com/elastic/beats/compare/v7.0.0-alpha2...master[Check the HEAD d
- Add support for ephemeral containers in kubernetes autodiscover and `add_kubernetes_metadata`. {pull}22389[22389] {pull}22439[22439]
- Added support for wildcard fields and keyword fallback in beats setup commands. {pull}22521[22521]
- Fix polling node when it is not ready and monitor by hostname {pull}22666[22666]
- Add tini as init system in docker images {pull}22137[22137]

*Auditbeat*

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,16 @@ LABEL \
ENV ELASTIC_CONTAINER "true"
ENV PATH={{ $beatHome }}:$PATH

# Add an init process, check the checksum to make sure it's a match
RUN set -e ; \
TINI_VERSION='v0.19.0' ; \
TINI_BIN='tini-amd64' ; \
TINI_SHA256='93dcc18adc78c65a028a84799ecf8ad40c936fdfc5f2a57b1acda5a8117fa82c' ; \
curl --retry 8 -S -L -O "https://github.com/krallin/tini/releases/download/${TINI_VERSION}/${TINI_BIN}" ; \
echo "${TINI_SHA256} ${TINI_BIN}" | sha256sum -c - ; \
mv "${TINI_BIN}" /usr/bin/tini ; \
chmod +x /usr/bin/tini

COPY docker-entrypoint /usr/local/bin/docker-entrypoint
RUN chmod 755 /usr/local/bin/docker-entrypoint

Expand All @@ -92,4 +102,4 @@ EXPOSE {{ $port }}
{{- end }}

WORKDIR {{ $beatHome }}
ENTRYPOINT ["/usr/local/bin/docker-entrypoint"]
ENTRYPOINT ["/usr/bin/tini", "--", "/usr/local/bin/docker-entrypoint"]
12 changes: 11 additions & 1 deletion dev-tools/packaging/templates/docker/Dockerfile.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,16 @@ LABEL \
ENV ELASTIC_CONTAINER "true"
ENV PATH={{ $beatHome }}:$PATH

# Add an init process, check the checksum to make sure it's a match
RUN set -e ; \
TINI_VERSION='v0.19.0' ; \
TINI_BIN='tini-amd64' ; \
TINI_SHA256='93dcc18adc78c65a028a84799ecf8ad40c936fdfc5f2a57b1acda5a8117fa82c' ; \
curl --retry 8 -S -L -O "https://github.com/krallin/tini/releases/download/${TINI_VERSION}/${TINI_BIN}" ; \
echo "${TINI_SHA256} ${TINI_BIN}" | sha256sum -c - ; \
mv "${TINI_BIN}" /usr/bin/tini ; \
chmod +x /usr/bin/tini

COPY docker-entrypoint /usr/local/bin/docker-entrypoint
RUN chmod 755 /usr/local/bin/docker-entrypoint

Expand All @@ -80,5 +90,5 @@ EXPOSE {{ $port }}
{{- end }}

WORKDIR {{ $beatHome }}
ENTRYPOINT ["/usr/local/bin/docker-entrypoint"]
ENTRYPOINT ["/usr/bin/tini", "--", "/usr/local/bin/docker-entrypoint"]
CMD ["-environment", "container"]

0 comments on commit 863aec4

Please sign in to comment.