Docker init Systems
There are a number of init systems used on docker containers, many are the defaults that ship with the standard Linux distributions, e.g. systemd which is particularly popular on the larger comprehensive distributions.
When creating my own imaged I have generally is the S6-RC init system, most if not all have been built on the latest Apline Linux as base image. Some examples:
- mailserver (yes, while I have got this to operate it needs some/a lot of cleanup and consolidation, including the main wiki documenation)
I have also used supervisord system where it was simple to follow the formula from the image supplier to add functionality. Some examples:
There are other init systems out there that I have not looked into, including a number of legacy init systems that are no longer supported.
s6 supervision rc system
I decided to build this container image based upon Alpine Linux using the S6 init system. The Skarnet.org is the S6 authors web site and main repository. S6 seems to be one of the most performant small init systems available, however it is not very easy to use. I could really use a front-end to help with the management.
s6 Service Driectories
The s6-rc service directories are stored at /etc/s6-overlay/s6-rc.d/
.
sub-directory | Must | Comment | |
---|---|---|---|
├── named | *1 | Service, longrun type, as required | |
│ ├── dependencies.d | * | Mandatory sub-directory with of dependent services as sub-directories | |
│ │ ├── base | built in base services | ||
│ │ └── pre_start_script | User pre start script (if required) | ||
│ ├── producer-for | *1 | file required for logging | |
│ └ named-log | *1 | file content with name of logging service | |
│ ├── run | * | File containing the service run script | |
│ └ #!/command/execlineb -P
fdmove -c 2 1
/usr/sbin/named -f -4
| * | file content with service to run. Note service must run in foreground | |
│ ├── timeout-down | optional file with timeout down, integer in milliseconds | ||
│ └ 180000 | *1 | file content with name of logging service | |
│ ├── timeout-up | optional file with timeout up, integer in milliseconds | ||
│ └ 30000 | *1 | file content with name of logging service | |
│ └── type | * | mandatory file containing service type, in this case longrun | |
│ └ longrun | *1 | file content with type of service | |
├── named-log | |||
│ ├── consumer-for | |||
│ ├── dependencies.d | |||
│ │ └── named-log-prepare | |||
│ ├── pipeline-name | |||
│ ├── run | |||
│ └── type | |||
├── named-log-prepare | |||
│ ├── dependencies.d | |||
│ │ ├── base | |||
│ │ └── pre_start_script | |||
│ ├── type | |||
│ └── up | |||
└── pre_start_script | |||
├── dependencies.d | |||
│ └── base | |||
├── type | |||
└── up |
s6 commands
docker builtin basic init
In the docker run command the --init
flag can be used to specify an init process is used. This causes docker to use tini as an init system on process 1, instead of the first docker command. Tini is a very basic init system specifically for containers that reaps zombie processes and preforms signal forwarding.
In docker compose add the directive init: true
see example below:
References
- just-containers/s6-overlay (Version 3.2.0.2 as of 2024-10-11, last checked 2024-10-13), note only a minor change since previous version
- The s6-rc-compile program Describes the functionality of the S6-rc system
It seems that the authors source pages skarnet.org are often down or otherwise slow and reliable. An alternative mirror is [https://skarnet.github.io/|skarnet.github.io]]
Other Supervisor software discussions:
- Choosing an init process for multi-process containers - Interesting discussion on different init systems, current at that time. (Seems relevant now too.)
- supervisord: Supervisor: A Process Control System