All Projects → chazomaticus → Minit

chazomaticus / Minit

Licence: zlib
minimalist init implementation for containers

Programming Languages

c
50402 projects - #5 most used programming language

Projects that are alternatives of or similar to Minit

natick
natickOS - A minimal, lightweight, research Linux Distribution
Stars: ✭ 33 (-26.67%)
Mutual labels:  minimal, init
Dockerfiles
Docker Projects Collection
Stars: ✭ 43 (-4.44%)
Mutual labels:  containers
Verwalter
A tool which manages cluster of services
Stars: ✭ 34 (-24.44%)
Mutual labels:  containers
Components
Example Components (Built with Tonic)
Stars: ✭ 42 (-6.67%)
Mutual labels:  minimal
Dedockify
Reverse engineer Docker images into Dockerfiles.
Stars: ✭ 36 (-20%)
Mutual labels:  containers
Cilium
eBPF-based Networking, Security, and Observability
Stars: ✭ 10,256 (+22691.11%)
Mutual labels:  containers
Femto
A toy text editor with no dependencies written in Ruby
Stars: ✭ 34 (-24.44%)
Mutual labels:  minimal
Csi Gcs
Kubernetes CSI driver for Google Cloud Storage
Stars: ✭ 44 (-2.22%)
Mutual labels:  containers
Drupal Nginx Php Kubernetes
Demonstration of a set of NGINX and PHP-FPM containers running Drupal deployed to Kubernetes on the IBM Container Service. This is a work in progress.
Stars: ✭ 43 (-4.44%)
Mutual labels:  containers
Sentry
Kubernetes Object Validating Admission Controller
Stars: ✭ 40 (-11.11%)
Mutual labels:  containers
Amazon Vpc Cni Plugins
VPC CNI plugins for Amazon ECS and EKS.
Stars: ✭ 39 (-13.33%)
Mutual labels:  containers
Mesos Cli
Alternative Apache Mesos CLI
Stars: ✭ 37 (-17.78%)
Mutual labels:  containers
Nagios Plugins Linux
🐧 Nagios Plugins for Linux
Stars: ✭ 42 (-6.67%)
Mutual labels:  containers
Addon Lxdone
Allows OpenNebula to manage Linux Containers via LXD
Stars: ✭ 36 (-20%)
Mutual labels:  containers
Minischeme
Cat's Eye Technologies' fork of the original public-domain Mini-Scheme implementation, miniscm.
Stars: ✭ 43 (-4.44%)
Mutual labels:  minimal
Centos7 S2i Nodejs
DEPRECATED OpenShift S2I builder images for Node.js ✨
Stars: ✭ 34 (-24.44%)
Mutual labels:  containers
Karch
A Terraform module to create and maintain Kubernetes clusters on AWS easily, relying entirely on kops
Stars: ✭ 38 (-15.56%)
Mutual labels:  containers
Clair
Vulnerability Static Analysis for Containers
Stars: ✭ 8,356 (+18468.89%)
Mutual labels:  containers
Kapo
Wrap any command in a status socket
Stars: ✭ 45 (+0%)
Mutual labels:  containers
Giropops Monitoring
Full stack tools for monitoring containers and other stuff. ;)
Stars: ✭ 1,019 (+2164.44%)
Mutual labels:  containers

Minit

Minit is a minimalist init implementation designed for use inside containers, for instance as the root process in a Docker image.

https://github.com/chazomaticus/minit

Use

There are three ways to start using minit inside your container. The easiest, assuming you're using Docker, is to simply use one of the minit base images as a base for your own Docker image. See the example directory.

If your container will be running Ubuntu, you can also make use of the minit PPA to avoid building minit yourself. For another Docker example:

# This is roughly equivalent to add-apt-repository ppa:chazomaticus/minit.
RUN apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E007F6BD
RUN echo "deb http://ppa.launchpad.net/chazomaticus/minit/ubuntu quantal main" > /etc/apt/sources.list.d/minit.list

RUN apt-get update && apt-get upgrade -y && apt-get install -y minit # etc.

Lastly, you can simply build minit by running make (or otherwise compiling the .c file into an executable). Put the resulting executable in your container's filesystem and set it to run as the root process when your container starts.

Note that in Docker, you need to use an exec form of ENTRYPOINT or CMD, as opposed to a shell form to run minit. See for example the ENTRYPOINT docs. The minit base images set this up for you automatically.

Operation

When minit starts, it runs a startup process which defaults to /etc/minit/startup. When it's shutting down, minit runs a shutdown process which defaults to /etc/minit/shutdown. Minit will shut down for any of three reasons: minit receives SIGTERM or SIGINT (the latter for convenience when running in the foreground), the startup process exits with nonzero status, or minit is out of child processes. The shutdown process executes exactly once, regardless of the reason. After the shutdown process exits, minit will issue SIGTERM to all remaining processes, unless it's running as a normal, non-init process. Minit exits, with the status returned from the startup process, when there are no more child processes (including the shutdown process).

You can override the default startup and shutdown processes with command line arguments to minit: the first, if non-empty, specifies the path to the startup process, and the second, the shutdown process. Note that it's not possible to pass command line arguments to either process. However, minit's environment is passed unmolested, so you can pass data there.

Minit doesn't forward any signals (other than sending SIGTERM to every process, potentially as a result of receiving SIGTERM itself, when shutting down as described above).

Justification

If you need more than one process inside your container, it's important for the root process to behave like init(8). See baseimage-docker for a thorough explanation of what that means and the special considerations for init inside Docker. Minit solves the init problem in a dead-simple way.

Docker recommends running Supervisor as your container's root process if you need to start multiple services inside a single container. Sometimes, though, you don't want the overhead of a full Python stack tagging along with your nice clean container image.

Advantages vs. Supervisor:

  • No dependencies
  • Smaller (only about 11K in size vs. about 18M for Python and Supervisor reported by apt-get on a clean Trusty image)
  • Allows arbitrary commands in container startup and shutdown
  • Easier to control daemons that can't run in the foreground like Postfix

Disadvantages vs. Supervisor:

  • Doesn't monitor or restart services

Advantages vs. baseimage-docker:

  • Simpler to use
  • Easier to control exactly which services get started
  • Smaller (a Trusty image with minit added is about 275M vs. about 346M for baseimage-docker)
  • Works on any distro, not just Ubuntu

Disadvantages vs. baseimage-docker:

  • Doesn't automatically run all the services they deem essential

Similar Projects

Yelp came out with a project similar to minit a while back now called dumb-init. I haven't looked too closely at it, but here are what I've gathered the differences to be:

  • Dumb-init seems more oriented toward a single child process model, as evidenced by needing to specify it, args and all, on the command line. Minit executes startup and shutdown scripts that more easily allow control of any number of running processes.
  • Dumb-init forwards signals; minit doesn't. Kind of makes sense given the first point.

Otherwise, I think they're very similar.

Enjoy!

Thanks to Arachsys init for ideas and inspiration. Thanks to Ricardo Branco for their contributions.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].