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-initNo compatibility data collected yet for this library.
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.
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", "--"]`.
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.
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"]`.
Upgrade to `dumb-init` version 1.2.2 or newer to mitigate this race condition.
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.
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.
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.
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.
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"]`.