Git Product home page Git Product logo

minit's Introduction

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 up, it execs /etc/minit/startup, then goes to sleep waiting on children until it gets a SIGTERM (or SIGINT, so you can stop your container with Ctrl+C if you ran it in the foreground). When it gets one of those signals, it execs /etc/minit/shutdown and waits for it to finish, then kills all remaining processes with SIGTERM.

You can override the startup and shutdown scripts with command line arguments: the first, if non-empty, is run instead of /etc/minit/startup, and the second is run instead of /etc/minit/shutdown. Minit's environment is passed unmolested to the scripts, so if you need to pass arguments to them, do it environmentally.

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 6K 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

Enjoy!

Thanks to Arachsys init for ideas and inspiration.

minit's People

Contributors

chazomaticus avatar

Watchers

 avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.