Registry / devops / dumb-init

dumb-init

JSON →
library1.2.5.post1pypypiunverified

Dumb-init is a minimal init system for Linux containers, designed to run as PID 1. It acts as a simple process supervisor, properly handling signals sent to the container and reaping orphaned zombie processes, which is crucial for the graceful shutdown of applications and preventing resource leaks. The current version is 1.2.5.post1, and it maintains a steady, albeit infrequent, release cadence with minor updates and bug fixes.

pip install dumb-init
INSTALL
IMPORT
SIG · DUMB-INIT
D
dumb-init
devopspythonv1.2.5.post1
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

This Dockerfile demonstrates how to install and use `dumb-init` as the entrypoint for a Python application. `dumb-init` will become PID 1, properly forwarding signals to `my_app.py` and reaping any zombie processes. Ensure your `CMD` also uses JSON array syntax.

FROM python:3.9-slim-buster # Install dumb-init RUN pip install dumb-init WORKDIR /app COPY my_app.py . # Use dumb-init as the ENTRYPOINT # Must use JSON array syntax to ensure dumb-init is PID 1 ENTRYPOINT ["dumb-init", "--"] # Your actual application command CMD ["python", "my_app.py"]
dumb-init --version
Debug
Known issues
gotchaProcesses running as PID 1 in Linux containers (e.g., Docker) have special kernel behavior and do not correctly handle signals (like SIGTERM) or reap zombie child processes by default. Failing to use an init system like `dumb-init` can lead to containers that cannot be gracefully stopped or accumulate defunct processes.
fix
Always use `dumb-init` (or a similar init system like `tini`) as your container's `ENTRYPOINT` with JSON array syntax. For example: `ENTRYPOINT ["dumb-init", "--"]`.
affects: All versions, fundamental Linux container behavior
breakingVersions 1.2.2 and later changed the naming convention for pre-built binaries from Debian architecture names (e.g., `amd64`, `arm64`) to Linux kernel names (e.g., `x86_64`, `aarch64`). While older names might be kept for compatibility in some Debian packages, this could affect custom build systems or scripts relying on specific binary names.
fix
Update references to binary names in build scripts or Dockerfiles if you are directly accessing the `dumb-init` binary by its architecture-specific name, or ensure your package manager handles the aliasing.
affects: >=1.2.2
gotchaUsing the 'shell form' for `ENTRYPOINT` or `CMD` (e.g., `ENTRYPOINT dumb-init -- python my_app.py`) will cause `sh -c` to become PID 1, not `dumb-init`. This defeats the purpose of `dumb-init` as the shell will not correctly forward signals.
fix
Always use the JSON array (exec form) syntax for `ENTRYPOINT` and `CMD` when using `dumb-init` to ensure it is PID 1. Example: `ENTRYPOINT ["dumb-init", "--"]` and `CMD ["python", "my_app.py"]`.
affects: All versions
gotchaA race condition in versions prior to 1.2.2 could cause the child process to receive SIGHUP and SIGCONT signals very shortly after startup, particularly in some container or virtualization environments.
fix
Upgrade to `dumb-init` version 1.2.2 or newer to mitigate this race condition.
affects: <1.2.2
gotchaInstallation of `dumb-init` (version 1.2.5.post1) has been reported to fail on macOS with Python 3.12.4 and Poetry, likely due to issues with PEP 517 builds.
fix
Consider using an earlier Python version or a different dependency manager on macOS, or consult the GitHub issues for potential workarounds or newer fixes if this specific environment is required.
affects: 1.2.5.post1 on macOS with Python 3.12.4 and Poetry
Errors
Common errors & fixes
exec: "dumb-init": executable file not found in $PATH
The dumb-init binary is not installed in the Docker image or is not located in any directory listed in the container's PATH environment variable.
fix
Install dumb-init within your Dockerfile using the appropriate package manager for your base image (e.g., `RUN apt-get update && apt-get install -y dumb-init` for Debian/Ubuntu, `RUN apk add dumb-init` for Alpine, or `RUN pip install dumb-init` if installed via PyPI). Ensure it's in a directory included in the system's PATH.
exec /usr/bin/dumb-init: exec format error
This error typically occurs when the dumb-init binary inside the container is compiled for a different CPU architecture (e.g., AMD64) than the host system (e.g., ARM64 Mac), or vice-versa.
fix
Ensure that the Docker image, including the dumb-init binary, is built specifically for the target host architecture. Use `docker build --platform=linux/arm64` or `docker build --platform=linux/amd64` to specify the architecture during image creation, or use a base image that matches the desired architecture.
Container exits with status 143
This exit code (143) often indicates that the process received a SIGTERM signal (15), which was not handled gracefully, and it exited without its own explicit exit status. dumb-init forwards SIGTERM to its child process, and if the child doesn't handle it, it will be terminated.
fix
Implement proper SIGTERM signal handling within your application to allow for a graceful shutdown. Ensure dumb-init is set as the `ENTRYPOINT` in your Dockerfile using JSON array syntax (`ENTRYPOINT ["dumb-init", "--"]`) to ensure it runs as PID 1 and reliably forwards signals to your application.
dumb-init npm install: No such file or directory
When `dumb-init` is instructed to run a command like `npm install` directly using list syntax in `CMD` or `command` (e.g., `CMD ["npm", "install"]`), it attempts to execute 'npm install' as a single binary, which does not exist. This is because multi-word commands need to be executed by a shell.
fix
Wrap multi-word commands that need shell interpretation within a shell command. For example, in a Dockerfile `CMD ["bash", "-c", "npm install && npm run start"]` or in `docker-compose.yml` `command: ["bash", "-c", "npm install; npm run start"]`.
Upgrade
Version history
1.2.5.post1latest on PyPI · released Apr 26, 2022
Audit
Dependencies
libc6requiredRuntime dependency for the statically-linked C binary on Linux systems.
gccoptionalRequired for compiling the C binary if pre-built wheels are not available for your platform during pip installation.
Agent activity
18 hits · last 30 days
node
18
Resources
dumb-init — pip install dumb-init · libregistry