systemd

CoreOS's init system

systemd Overview

CoreOS uses systemd as its primary init system. Systemd is well supported in many Linux distros, making it familiar to most engineers. Every aspect of CoreOS is deeply integrated with systemd.

We chose systemd for a few primary reasons:

  • Performance
    Systemd boots extremely fast, with our goal to keep it under 1s.
  • Journal
    Systemd's logging journal has modern features such as JSON export, forward sealing, and indexing for fast querying.
  • Socket Activation
    While this might be a bit of a throw back to the inetd days, we think socket activation is particularly useful for inter-service dependency management.
[Unit]
Description=My Service
Requires=docker.service
After=docker.service

[Service]
ExecStart=/usr/bin/docker run busybox /bin/sh -c "while true; do echo Hello World; sleep 1; done"

[Install]
WantedBy=local.target
Example service file that runs a docker container.

Systemd has an extremely rich syntax that can describe the attributes of a particular service. Your services can express hard or soft dependencies, the order of launch relative to those dependencies, and identify conflicting services. Docker containers are much easier to manage when you can specify whether they automatically restart per container and customize the timing for restarting.

Service files are just plain text documents — they are easy to edit and store in version control. Generating service files on demand is also very simple. You can even prevent services from being started or stopped manually if you're controlling systemd programmatically.