Docker init Systems

Back  
 Next

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:

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

S6 Service directories

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

Basic 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:

docker-compose.yml snippet

References

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:

/app/www/public/data/pages/docker_notes/init.txt · Last modified: 2024-08-24 Sat wk34 22:17
CC Attribution-Share Alike 4.0 International Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 4.0 International