github.com/zhuohuang-hust/src-cbuild@v0.0.0-20230105071821-c7aab3e7c840/mergeCode/tini/tpl/README.md.in (about)

     1  <!--
     2  
     3  #####################################
     4  # THIS FILE IS AUTOGENERATED!       #
     5  # Edit ./tpl/README.md.in instead   #
     6  #####################################
     7  
     8  -->
     9  
    10  
    11  Tini - A tiny but valid `init` for containers
    12  =============================================
    13  
    14  [![Build Status](https://travis-ci.org/krallin/tini.svg?branch=master)](https://travis-ci.org/krallin/tini)
    15  
    16  Tini is the simplest `init` you could think of.
    17  
    18  All Tini does is spawn a single child (Tini is meant to be run in a container),
    19  and wait for it to exit all the while reaping zombies and performing
    20  signal forwarding.
    21  
    22  
    23  Using Tini
    24  ----------
    25  
    26  *NOTE: There are [pre-built Docker images available for Tini][10]. If
    27  you're currently using an Ubuntu or CentOS image as your base, you can use
    28  one of those as a drop-in replacement.*
    29  
    30  *NOTE: There are Tini packages for Alpine Linux and NixOS. See below for
    31  installation instructions.*
    32  
    33  Add Tini to your container, and make it executable. Then, just invoke Tini
    34  and pass your program and its arguments as arguments to Tini.
    35  
    36  In Docker, you will want to use an entrypoint so you don't have to remember
    37  to manually invoke Tini:
    38  
    39      # Add Tini
    40      ENV TINI_VERSION v@tini_VERSION_MAJOR@.@tini_VERSION_MINOR@.@tini_VERSION_PATCH@
    41      ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini /tini
    42      RUN chmod +x /tini
    43      ENTRYPOINT ["/tini", "--"]
    44  
    45      # Run your program under Tini
    46      CMD ["/your/program", "-and", "-its", "arguments"]
    47      # or docker run your-image /your/program ...
    48  
    49  Note that you *can* skip the `--` under certain conditions, but you might
    50  as well always include it to be safe. If you see an error message that
    51  looks like `tini: invalid option -- 'c'`, then you *need* to add the `--`.
    52  
    53  Arguments for Tini itself should be passed like `-v` in the following example:
    54  `/tini -v -- /your/program`.
    55  
    56  *NOTE: The binary linked above is a 64-bit dynamically-linked binary.*
    57  
    58  
    59  ### Signed binaries ###
    60  
    61  The `tini` and `tini-static` binaries are signed using the key `595E85A6B1B4779EA4DAAEC70B588DFF0527A9B7`.
    62  
    63  You can verify their signatures using `gpg` (which you may install using
    64  your package manager):
    65  
    66      ENV TINI_VERSION v@tini_VERSION_MAJOR@.@tini_VERSION_MINOR@.@tini_VERSION_PATCH@
    67      ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini /tini
    68      ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini.asc /tini.asc
    69      RUN gpg --keyserver ha.pool.sks-keyservers.net --recv-keys 595E85A6B1B4779EA4DAAEC70B588DFF0527A9B7 \
    70       && gpg --verify /tini.asc
    71  
    72  
    73  ### Alpine Linux Package ###
    74  
    75  On Alpine Linux, you can use the following command to install Tini:
    76  
    77      apk add --update tini
    78      # Tini is now available at /sbin/tini
    79  
    80  
    81  ### NixOS ###
    82  
    83  Using Nix, you can use the following command to install Tini:
    84  
    85      nix-env --install tini
    86  
    87  ### ARM ###
    88  
    89  ARM images are available! Find the list of available platforms under the
    90  releases tab.
    91  
    92  
    93  Options
    94  -------
    95  
    96  ### Verbosity ###
    97  
    98  The `-v` argument can be used for extra verbose output (you can pass it up to
    99  3 times, e.g. `-vvv`).
   100  
   101  
   102  ### Subreaping ###
   103  
   104  By default, Tini needs to run as PID 1 so that it can reap zombies (by
   105  running as PID 1, zombies get re-parented to Tini).
   106  
   107  If for some reason, you cannot run Tini as PID 1, you should register Tini as
   108  a process subreaper instead (only in Linux >= 3.4), by either:
   109  
   110    + Passing the `-s` argument to Tini (`tini -s -- ...`)
   111    + Setting the environment variable `TINI_SUBREAPER`
   112      (e.g. `export TINI_SUBREAPER=`).
   113  
   114  This will ensure that zombies get re-parented to Tini despite Tini not running
   115  as PID 1.
   116  
   117  *NOTE: Tini will issue a warning if it detects that it isn't running as PID 1
   118  and isn't registered as a subreaper. If you don't see a warning, you're fine.*
   119  
   120  
   121  ### Process group killing ###
   122  
   123  By default, Tini only kills its immediate child process.  This can be
   124  inconvenient if sending a signal to that process does have the desired
   125  effect.  For example, if you do
   126  
   127      docker run krallin/ubuntu-tini sh -c 'sleep 10'
   128  
   129  and ctrl-C it, nothing happens: SIGINT is sent to the 'sh' process,
   130  but that shell won't react to it while it is waiting for the 'sleep'
   131  to finish.
   132  
   133  With the `-g` option, Tini kills the child process group , so that
   134  every process in the group gets the signal. This corresponds more
   135  closely to what happens when you do ctrl-C etc. in a terminal: The
   136  signal is sent to the foreground process group.
   137  
   138  
   139  More
   140  ----
   141  
   142  ### Existing Entrypoint ###
   143  
   144  Tini can also be used with an existing entrypoint in your container!
   145  
   146  Assuming your entrypoint was `/docker-entrypoint.sh`, then you would use:
   147  
   148      ENTRYPOINT ["/tini", "--", "/docker-entrypoint.sh"]
   149  
   150  
   151  ### Statically-Linked Version ###
   152  
   153  Tini has very few dependencies (it only depends on libc), but if your
   154  container fails to start, you might want to consider using the statically-built
   155  version instead:
   156  
   157      ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini-static /tini
   158  
   159  
   160  ### Size Considerations ###
   161  
   162  Tini is a very small file (in the 10KB range), so it doesn't add much weight
   163  to your container.
   164  
   165  The statically-linked version is bigger, but still < 1M.
   166  
   167  
   168  Building Tini
   169  -------------
   170  
   171  If you'd rather not download the binary, you can build Tini by running
   172  `cmake . && make`.
   173  
   174  Before building, you probably also want to run:
   175  
   176      export CFLAGS="-DPR_SET_CHILD_SUBREAPER=36 -DPR_GET_CHILD_SUBREAPER=37"
   177  
   178  This ensure that even if you're building on a system that has old Linux Kernel
   179  headers (< 3.4), Tini will be built with child subreaper support. This is
   180  usually what you want if you're going to use Tini with Docker (if your host
   181  Kernel supports Docker, it should also support child subreapers).
   182  
   183  
   184  Understanding Tini
   185  ------------------
   186  
   187  After spawning your process, Tini will wait for signals and forward those
   188  to the child process, and periodically reap zombie processes that may be
   189  created within your container.
   190  
   191  When the "first" child process exits (`/your/program` in the examples above),
   192  Tini exits as well, with the exit code of the child process (so you can
   193  check your container's exit code to know whether the child exited
   194  successfully).
   195  
   196  
   197  Debugging
   198  ---------
   199  
   200  If something isn't working just like you expect, consider increasing the
   201  verbosity level (up to 3):
   202  
   203      tini -v    -- bash -c 'exit 1'
   204      tini -vv   -- true
   205      tini -vvv  -- pwd
   206  
   207  
   208  Authors
   209  =======
   210  
   211  Maintainer:
   212  
   213    + [Thomas Orozco][20]
   214  
   215  Contributors:
   216  
   217    + [Tianon Gravi][30]
   218    + [David Wragg][31]
   219    + [Michael Crosby][32]
   220  
   221  Special thanks to:
   222  
   223    + [Danilo Bürger][40] for packaging Tini for Alpine
   224    + [Asko Soukka][41] for packaging Tini for Nix
   225  
   226  
   227    [10]: https://github.com/krallin/tini-images
   228    [20]: https://github.com/krallin/
   229    [30]: https://github.com/tianon
   230    [31]: https://github.com/dpw
   231    [32]: https://github.com/crosbymichael
   232    [40]: https://github.com/danilobuerger
   233    [41]: https://github.com/datakurre