Scripts2026年7月14日·1 分钟阅读

dumb-init — Minimal Init System for Linux Containers

dumb-init is a lightweight process supervisor and init system designed specifically for Docker containers. It handles signal forwarding and zombie process reaping that PID 1 must perform inside a container.

Agent 就绪

先审查再安装

这个资产需要先审查。复制的指令会要求 Agent dry-run、列出写入项,确认后再继续。

Needs Confirmation · 64/100策略:需确认
Agent 入口
任意 MCP/CLI Agent
类型
Skill
安装
Single
信任
信任等级:Established
入口
dumb-init Container Init
先审查命令
npx -y tokrepo@latest install 583c9cf4-7f1c-11f1-9bc6-00163e2b0d79 --target codex

先 dry-run,确认写入项后再运行此命令。

Introduction

dumb-init is a simple process supervisor created by Yelp that solves two critical problems in Docker containers: signal forwarding and zombie process reaping. When your application runs as PID 1 inside a container, it does not receive signals like SIGTERM correctly and cannot clean up orphaned child processes. dumb-init acts as PID 1, forwarding signals to your application and reaping zombies automatically.

What dumb-init Does

  • Runs as PID 1 inside a container and spawns your application as a child process
  • Forwards signals (SIGTERM, SIGINT, SIGHUP, etc.) to the child process group
  • Reaps zombie processes that accumulate when child processes are not properly waited on
  • Adds under 700 KB to container image size as a static binary
  • Exits with the same exit code as the child process for correct orchestrator behavior

Architecture Overview

dumb-init is written in C and compiles to a small static binary. When started, it forks and execs the command specified in its arguments. It installs signal handlers for all standard signals and forwards them to the child process group using kill with a negative PID. A SIGCHLD handler calls waitpid in a loop to reap any zombie children. The entire codebase is under 200 lines of C.

Self-Hosting & Configuration

  • Download the static binary from GitHub releases; no package manager required
  • Place it as the ENTRYPOINT in your Dockerfile before your CMD
  • Use --single-child flag to forward signals only to the direct child, not the process group
  • Remap signals with --rewrite flag (e.g., --rewrite 15:2 converts SIGTERM to SIGINT)
  • No configuration files; all behavior is controlled via command-line flags

Key Features

  • Tiny footprint — static binary under 700 KB with no dependencies
  • Correct signal handling — ensures SIGTERM reaches your application for graceful shutdown
  • Zombie reaping — prevents zombie process accumulation in long-running containers
  • Signal rewriting — remap one signal to another for applications that only handle SIGINT
  • Process group forwarding — sends signals to the entire child process group by default

Comparison with Similar Tools

  • tini — similar minimal init with comparable features; dumb-init adds signal rewriting
  • s6-overlay — full init and supervision suite; dumb-init is simpler with a single purpose
  • supervisord — Python-based process manager; dumb-init is a tiny C binary for init duties only
  • bash exec — exec replaces the shell but does not reap zombies; dumb-init handles both
  • Docker --init — Docker's built-in init (uses tini); dumb-init offers signal rewriting and explicit control

FAQ

Q: Why can't my application just be PID 1? A: PID 1 has special signal semantics in Linux — it does not receive default signal handlers and must explicitly handle SIGTERM. It also must reap zombie children.

Q: How does dumb-init compare to Docker --init? A: Docker --init uses tini under the hood. dumb-init adds signal rewriting and process group forwarding options.

Q: Does dumb-init work with Kubernetes? A: Yes. Set it as the ENTRYPOINT in your container image. Kubernetes sends SIGTERM for graceful shutdown, and dumb-init forwards it correctly.

Q: What is the performance overhead? A: Negligible. dumb-init adds one fork/exec at startup and one signal handler invocation per signal received.

Sources

讨论

登录后参与讨论。
还没有评论,来写第一条吧。

相关资产