A tiny but valid init for containers
Go to file
Thomas Orozco fb66ef7f6f Fix typo in README 2015-03-01 11:58:49 -05:00
test Add a static version as well 2015-03-01 11:46:29 -05:00
.dockerignore Just copy from the image in ddist 2015-02-28 19:12:23 -05:00
.gitignore Refactor build process 2015-02-28 19:04:46 -05:00
Dockerfile Add a valgind test 2015-03-01 11:03:48 -05:00
LICENSE Initial commit 2015-02-22 13:23:44 -08:00
Makefile Add a static version as well 2015-03-01 11:46:29 -05:00
README.md Fix typo in README 2015-03-01 11:58:49 -05:00
config.mk Bump version to 0.3.0 2015-03-01 11:56:37 -05:00
ddist.sh Add a static version as well 2015-03-01 11:46:29 -05:00
dtest.sh Refactor build process 2015-02-28 19:04:46 -05:00
tini.c Add version in usage, improve usage 2015-02-28 19:42:36 -05:00

README.md

Tini - A tiny but valid init for containers

Tini is the simplest init you could think of.

All Tini does is spawn a single child (Tini is meant to be run in a container), and wait for it to exit all the while reaping zombies and performing signal forwarding.

Using Tini

Add Tini to your container, and make it executable. Then, just invoke Tini and pass your program and its arguments as arguments to Tini.

In Docker, you will want to use an entrypoint so you don't have to remember to manually invoke Tini:

# Add Tini
ENV TINI_VERSION v0.3.0
ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini /tini
RUN chmod +x /tini
ENTRYPOINT ["/tini", "--"]

# Run your program under Tini
CMD ["/your/program", "-and", "-its", "arguments"]
# or docker run your-image /your/program ...

Note that you can skip the -- under certain conditions, but you might as well always include it to be safe. If you see an error message that looks like tini: invalid option -- 'c', then you need to add the --.

Arguments Tini itself are passed like so: /tini -v -- /your/program. The only supported argument at this time is -v, for extra verbosity (you can pass it up to 4 times, e.g. -vvvv).

NOTE: The binary linked above is a 64-bit dynamically-linked binary.

Existing Entrypoint

Tini can also be used with an existing entrypoint in your container!

Assuming your entrypoint was /docker-entrypoint.sh, then you would use:

ENTRYPOINT ["/tini", "--", "/docker-entrypoint.sh"]

Statically-Linked Version

Tini has very few dependencies (it only depends on libc), but if your container fails to start, you might want to consider using the statically-built version instead:

ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini-static /tini

Size Considerations

Tini is a very small file (in the 10KB range), so it doesn't add much weight to your container.

The statically-linked version is bigger, but still < 1M.

Building Tini

If you'd rather not download the binary, you can build Tini by just running make (i.e. there is no ./configure script).

Understanding Tini

After spawning your process, Tini will wait for signals and forward those to the child process, and periodically reap zombie processes that may be created within your container.

Debugging

If something isn't working just like you expect, consider increasing the verbosity level (up to 4):

tini -v    -- bash -c 'exit 1'
tini -vv   -- true
tini -vvv  -- pwd
tini -vvvv -- ls