From db53ed45e31bbe23f3a3b5fcca35aa023f272fcd Mon Sep 17 00:00:00 2001 From: Chris Kuehl Date: Mon, 25 Jul 2016 22:02:24 -0700 Subject: [PATCH 1/2] Expand on how to use in a Dockerfile --- README.md | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 667e8b4..b61feb8 100644 --- a/README.md +++ b/README.md @@ -186,7 +186,22 @@ then just `pip install dumb-init`. ## Usage Once installed inside your Docker container, simply prefix your commands with -`dumb-init`. For example: +`dumb-init`. + +Within a Dockerfile, it's a good practice to use dumb-init as your container's +entrypoint. An "entrypoint" is a partial command that gets prepended to your +`CMD` instruction, making it a great fit for dumb-init: + +```bash +# Runs "/usr/bin/dumb-init -- /my/script --with --args" +ENTRYPOINT ["/usr/bin/dumb-init", "--"] +CMD ["/my/script", "--with", "--args"] +``` + +If you declare an entrypoint in a base image, any images that descend from it +don't need to also declare dumb-init. They can just set a `CMD` as usual. + +For interactive one-off usage, you can just prepend it manually: $ docker run my_container dumb-init python -c 'while True: pass' @@ -231,7 +246,7 @@ your machine. * [Docker and the PID 1 zombie reaping problem (Phusion Blog)](https://blog.phusion.nl/2015/01/20/docker-and-the-pid-1-zombie-reaping-problem/) * [Trapping signals in Docker containers (@gchudnov)](https://medium.com/@gchudnov/trapping-signals-in-docker-containers-7a57fdda7d86) -* [pgctl](https://github.com/Yelp/pgctl) +* [tini](https://github.com/krallin/tini), an alterative to dumb-init [daemontools]: http://cr.yp.to/daemontools.html From e5783199acc88de6371eaa30b390a5c0651cd69e Mon Sep 17 00:00:00 2001 From: Chris Kuehl Date: Thu, 28 Jul 2016 13:53:25 -0700 Subject: [PATCH 2/2] Dockerfile syntax highlighting is a thing now --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index b61feb8..f405835 100644 --- a/README.md +++ b/README.md @@ -157,7 +157,7 @@ If you don't have an internal apt server, you can use `dpkg -i` to install the One possibility is with the following commands in your Dockerfile: -```bash +```Dockerfile RUN wget https://github.com/Yelp/dumb-init/releases/download/v1.1.2/dumb-init_1.1.2_amd64.deb RUN dpkg -i dumb-init_*.deb ``` @@ -168,7 +168,7 @@ RUN dpkg -i dumb-init_*.deb Since dumb-init is released as a statically-linked binary, you can usually just plop it into your images. Here's an example of doing that in a Dockerfile: -```bash +```Dockerfile RUN wget -O /usr/local/bin/dumb-init https://github.com/Yelp/dumb-init/releases/download/v1.1.2/dumb-init_1.1.2_amd64 RUN chmod +x /usr/local/bin/dumb-init ``` @@ -192,7 +192,7 @@ Within a Dockerfile, it's a good practice to use dumb-init as your container's entrypoint. An "entrypoint" is a partial command that gets prepended to your `CMD` instruction, making it a great fit for dumb-init: -```bash +```Dockerfile # Runs "/usr/bin/dumb-init -- /my/script --with --args" ENTRYPOINT ["/usr/bin/dumb-init", "--"] CMD ["/my/script", "--with", "--args"]