当前位置: 首页 > 软件库 > 云计算 > >

tini

A tiny but valid `init` for containers
授权协议 MIT License
开发语言 C/C++
所属分类 云计算
软件类型 开源软件
地区 不详
投 递 者 云英才
操作系统 跨平台
开源组织
适用人群 未知
 软件概览

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 performingsignal forwarding.

Why Tini?

Using Tini has several benefits:

  • It protects you from software that accidentally creates zombie processes,which can (over time!) starve your entire system for PIDs (and make itunusable).
  • It ensures that the default signal handlers work for the software you runin your Docker image. For example, with Tini, SIGTERM properly terminatesyour process even if you didn't explicitly install a signal handler for it.
  • It does so completely transparently! Docker images that work without Tiniwill work with Tini without any changes.

If you'd like more detail on why this is useful, review this issue discussion:What is advantage of Tini?.

Using Tini

NOTE: If you are using Docker 1.13 or greater, Tini is included in Dockeritself. This includes all versions of Docker CE. To enable Tini, just pass the--init flag to docker run.

NOTE: There are pre-built Docker images available for Tini. Ifyou're currently using an Ubuntu or CentOS image as your base, you can useone of those as a drop-in replacement.

NOTE: There are Tini packages for Alpine Linux and NixOS. See below forinstallation instructions.

Add Tini to your container, and make it executable. Then, just invoke Tiniand 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 rememberto manually invoke Tini:

# Add Tini
ENV TINI_VERSION v0.19.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 mightas well always include it to be safe. If you see an error message thatlooks like tini: invalid option -- 'c', then you need to add the --.

Arguments for Tini itself should be passed like -v in the following example:/tini -v -- /your/program.

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

Signed binaries

The tini and tini-static binaries are signed using the key 595E85A6B1B4779EA4DAAEC70B588DFF0527A9B7.

You can verify their signatures using gpg (which you may install usingyour package manager):

ENV TINI_VERSION v0.19.0
ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini /tini
ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini.asc /tini.asc
RUN gpg --batch --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 595E85A6B1B4779EA4DAAEC70B588DFF0527A9B7 \
 && gpg --batch --verify /tini.asc /tini
RUN chmod +x /tini

Verifying binaries via checksum

The tini and tini-static binaries have generated checksums (SHA1 and SHA256).

You can verify their checksums using sha1sum and sha256sum (which you may install usingyour package manager):

ENV TINI_VERSION v0.19.0
RUN wget --no-check-certificate --no-cookies --quiet https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini-amd64 \
    && wget --no-check-certificate --no-cookies --quiet https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini-amd64.sha256sum \
    && echo "$(cat tini-amd64.sha256sum)" | sha256sum -c

Alpine Linux Package

On Alpine Linux, you can use the following command to install Tini:

RUN apk add --no-cache tini
# Tini is now available at /sbin/tini
ENTRYPOINT ["/sbin/tini", "--"]

NixOS

Using Nix, you can use the following command to install Tini:

nix-env --install tini

Debian

On Debian (Buster or newer), you can use the following command to install Tini:

apt-get install tini

Note that this installs /usr/bin/tini (and /usr/bin/tini-static), not /tini.

Arch Linux

On Arch Linux, there is a package available on the AUR.Install using the official instructionsor use an AUR helper:

pacaur -S tini

Other Platforms

ARM and 32-bit binaries are available! You can find the complete list ofavailable binaries under the releases tab.

Options

Verbosity

The -v argument can be used for extra verbose output (you can pass it up to3 times, e.g. -vvv).

Subreaping

By default, Tini needs to run as PID 1 so that it can reap zombies (byrunning as PID 1, zombies get re-parented to Tini).

If for some reason, you cannot run Tini as PID 1, you should register Tini asa process subreaper instead (only in Linux >= 3.4), by either:

  • Passing the -s argument to Tini (tini -s -- ...)
  • Setting the environment variable TINI_SUBREAPER(e.g. export TINI_SUBREAPER=).

This will ensure that zombies get re-parented to Tini despite Tini not runningas PID 1.

NOTE: Tini will issue a warning if it detects that it isn't running as PID 1and isn't registered as a subreaper. If you don't see a warning, you're fine.

Remapping exit codes

Tini will reuse the child's exit code when exiting, but occasionally, this maynot be exactly what you want (e.g. if your child exits with 143 after receivingSIGTERM). Notably, this can be an issue with Java apps.

In this case, you can use the -e flag to remap an arbitrary exit code to 0.You can pass the flag multiple times if needed.

For example:

tini -e 143 -- ...

Process group killing

By default, Tini only kills its immediate child process. This can beinconvenient if sending a signal to that process does not have the desiredeffect. For example, if you do

docker run krallin/ubuntu-tini sh -c 'sleep 10'

and ctrl-C it, nothing happens: SIGINT is sent to the 'sh' process,but that shell won't react to it while it is waiting for the 'sleep'to finish.

With the -g option, Tini kills the child process group , so thatevery process in the group gets the signal. This corresponds moreclosely to what happens when you do ctrl-C etc. in a terminal: Thesignal is sent to the foreground process group.

Parent Death Signal

Tini can set its parent death signal, which is the signal Tini should receivewhen its parent exits. To set the parent death signal, use the -p flag withthe name of the signal Tini should receive when its parent exits:

tini -p SIGTERM -- ...

NOTE: See this PR discussion to learn more about the parent death signaland use cases.

More

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 yourcontainer fails to start, you might want to consider using the statically-builtversion 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 weightto 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 runningcmake . && make.

Before building, you probably also want to run:

export CFLAGS="-DPR_SET_CHILD_SUBREAPER=36 -DPR_GET_CHILD_SUBREAPER=37"

This ensure that even if you're building on a system that has old Linux Kernelheaders (< 3.4), Tini will be built with child subreaper support. This isusually what you want if you're going to use Tini with Docker (if your hostKernel supports Docker, it should also support child subreapers).

Understanding Tini

After spawning your process, Tini will wait for signals and forward thoseto the child process, and periodically reap zombie processes that may becreated within your container.

When the "first" child process exits (/your/program in the examples above),Tini exits as well, with the exit code of the child process (so you cancheck your container's exit code to know whether the child exitedsuccessfully).

Debugging

If something isn't working just like you expect, consider increasing theverbosity level (up to 3):

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

Authors

Maintainer:

Contributors:

Special thanks to:

  • 使用ubuntu18.04打包镜像启动失败报错信息: /bin/sh: 1: tini: not found 需要安装tini 而ubuntu本身软件源没有这个软件包 apt install -y tini 报错 Unable to locate package 解决方法: dockerfile新增 RUN echo "deb http://kr.archive.ubuntu.com/ubuntu

  • 1)tini启动 启动应用 pid 不等于1 2) 上海时区 3) 容器内应用 进程普通用户启动   [ucmed@VM_210_13_centos tomcat]$ more Dockerfile FROM tomcat:8.5.66-jdk8-openjdk VOLUME /tmp ENV TZ=Asia/Shanghai ENV TINI_VERSION v0.19.0 ADD https:

  • 一般的docker镜像为了节省空间,通常是没有安装systemd或者sysvint这类初始化系统的进程。一旦容器的起始进程不稳定将会产生大量的僵尸进程,影响宿主系统的运行。 缺少init的容器 init系统有以下几个特点: 它是系统的第一个进程,负责产生其他所有用户进程。 init 以守护进程方式存在,是所有其他进程的祖先。 它主要负责: 1.启动守护进程 2.回收孤儿进程 3.将操作系统信号转发

  • Latex 添加参考文献 1. 添加文件 在 .tex 文件的同级路径下添加 .bib 文件,在文件中复制下述格式的代码(代码可以在 google 学术 或者 百度学术里面的: 引用 - bibtex 中获得)。 这里我们以文件名 bibtex.bib 为例,文件内容如下: @article{guan2020clinical, title={Clinical characteristics o

  • 转载自:http://www.cnblogs.com/dragondove/p/6389177.html 在算法分析中,我们将语句总的执行次数记为T(n)进而分析T(n)随n的变化情况确认T(n)的数量级。一般情况下,T(n)随n增大变化最缓慢的算法为最优算法。 根据定义,T(n)的求法是很简单的,也就是简单的数数。举个例子: int i; for(i=0;i<n;i++){/*...*/};这里

  • 转自http://zmp1123.blog.163.com/blog/static/1193291592013314581911/ 设n 个不同整数排好序后存于T[0:n-1]中,若存在一个下标i,0≤i<n,是的T[i]=i,设计一个有效地算法找到这个下标。要求算法在 最坏情况下的计算时间为O(logn)。 算法描述如下: 由于n 个整数是不同的,因此对任意0≤i<n-1 有T[i]≤T[i+1

  • 假设你有一个file_name='data5.txt'的文本, file=open(file_name,'r') data = file.readlines() # 必须选择readlines,不能选择read for i in data: #你会发现i其实是一个字符串,如果你要读取数据,就选择字符串的多少位。 print(i[0])常规的还有 # a=''.join(line.s

  • \r将光标移到一行的开始,覆盖 \r是将光标移到一行的开始,所以\r之后的内容会覆盖掉上次打印的内容 print('你好吗?\r朋友') <<朋友吗? "\n"换行 打印结果分列在两行 print('i love you \ni love you too') << i love you i love you too "\t"制表符 打印结果中间隔了一个制表符 print('i love you

 相关资料
  • 组件 触发字符 mui.init min 创建子页面( subpage ) minsubpage 预加载页面( preload ) minpreload 刷新组件( pullRefresh ) minpullRefresh 手势事件( getures ) mingesture 侧滑返回( swipeback ) minswipeback 按键绑定(keyeventbind) minkeyevent

  • mui框架将很多功能配置都集中在mui.init方法中,要使用某项功能,只需要在mui.init方法中完成对应参数配置即可,目前支持在mui.init方法中配置的功能包括:创建子页面、关闭页面、手势事件配置、预加载、下拉刷新、上拉加载、设置系统状态栏背景颜色。 mui需要在页面加载时初始化很多基础控件,如监听返回键,因此务必在每个页面中调用 以下各配置模块在其对应文档中有详细阐述,请点击链接查看,

  • 当我设置部署目标iOS6+,然后构建时,第三个SDK会显示错误。 但是,当部署目标是iOS6时,它运行良好。真是难以置信!是任何人都可以帮助我,非常感谢!! 错误:

  • 每本新书都有一些最小的样板。为此目的,mdBook支持init命令. init命令使用如下: mdbook init 第一次使用init命令,将为您设置几个文件: book-test/ ├── book └── src ├── chapter_1.md └── SUMMARY.md src目录是你在写的markdown书。它包含所有源文件,配置文件等. book目录是您的书ht

  • Interactively creates or updates a package.json file. yarn init This command walks you through an interactive session to create a package.json file. Some defaults such as the license and initial versi

  • 名称 git-init - 创建一个空的 Git 仓库或重新初始化一个现有仓库 概要 git init [-q | --quiet] [--bare] [--template=<template_directory>] [--separate-git-dir <git dir>] [--shared[=<permissions>]] [directory] 描述

  • Init 帮助 Android 应用调度复杂的任务流(如应用初始化流程),如下一节图示的那种任务流,处理类型、优先级、多进程(像是每个进程都会执行application的onCreate),任务依赖,提高应用启动效率。 尽管Init设计的初衷是为了应用(application)初始化,但并不局限于此,它可以于应用在任何复杂的初始化流程。 Init不依赖于任何第三方库,使用Java concurre

  • gae-init gae-init is the easiest boilerplate to kick start new applications on Google App Engine using Python, Flask, RESTful, Bootstrap and tons of other cool features. Read the documentation, where