This page is read only. You can view the source, but not change it. Ask your administrator if you think this is wrong. {{tag>Alpine linux docker init s6 s6-rc}} ======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: *[[https://wiki.kptree.net/doku.php?id=docker_notes:docker-dns#docker_-_dns_server|DNS (ISC Bind9)]] *[[https://wiki.kptree.net/doku.php?id=docker_notes:docker-dhcp#docker_-_dhcp_server|DHCP server (ISC Kea)]] *[[https://wiki.kptree.net/doku.php?id=docker_notes:docker-deluge#docker_deluge_image_service|Torrent server (Deluge)]] *mailserver (yes, while I have got this to operate it needs some/a lot of cleanup and consolidation, including the main wiki documenation) *[[https://wiki.kptree.net/doku.php?id=docker_notes:docker-mailserver#docker_mailserver|Mail server (Postfix and Dovecot)]] *[[https://wiki.kptree.net/doku.php?id=docker_notes:docker-mailserver#mariadb|Mail server database and web interface (mariadb php nginx)]] *[[https://wiki.kptree.net/doku.php?id=docker_notes:docker-mailserver#roundcube_webmail|Web Mailserver (Roundcube, postgresdb)]] I have also used supervisord system where it was simple to follow the formula from the image supplier to add functionality. Some examples: *[[https://wiki.kptree.net/doku.php?id=docker_notes:docker-nextcloud#nextcloud_with_supervisord|Nextcloud (only example)]] 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 [[https://www.skarnet.org/software/s6/index.html|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 [[http://www.skarnet.org/software/s6/servicedir.html|Service directories]] The s6-rc service directories are stored at ''%%/etc/s6-overlay/s6-rc.d/%%''. ^ sub-directory ^ Must ^ Comment | | | ├── <fs large>**named**</fs> | *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 | | | │ └ <code> named-log</code> | *1 | file content with name of logging service | | | │ ├── run |* | File containing the service run script | | | │ └ <code> #!/command/execlineb -P fdmove -c 2 1 /usr/sbin/named -f -4 </code> |* | file content with service to run. Note service must run in foreground| | │ ├── timeout-down | |optional file with timeout down, integer in milliseconds | | │ └ <code> 180000</code> | *1 | file content with name of logging service | | | │ ├── timeout-up | |optional file with timeout up, integer in milliseconds | | │ └ <code> 30000</code> | *1 | file content with name of logging service | | | │ └── type |* |mandatory file containing service type, in this case longrun | | │ └ <code> longrun</code> | *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:| *''s6-svstat /run/service/servicename'' or ''s6-svstat /run/s6-rc/servicedirs/deluged'' - check a daemon status, longrun only! *''s6-rc -u change servicename'' - enable and start a daemon (up) *''s6-rc -d change servicename'' - disable and stop a daemon (down) *''s6-rc-db list all|services|oneshots|longruns|bundles'' - lists the nominated services in the active s6-rc-db *''s6-rc-db type servicename'' - Prints the type of servicename: oneshot, longrun or bundle *''s6-rc-db dependencies servicename'' - lists the dependencies in the servicename directory, i.e. in servicesname/dependencies.d *''s6-rc-db dependencies servicename'' - lists all the dependencies of servicename *''s6-rc-db -d|-u timeout servicename'' - lists the timeout, -d for timeout down and -u for timeout up BTW dont spell dependencies as dependancies and wonder why things don't work, lol the English language sucks. ++++ =====docker builtin basic init===== In the docker run command the ''%%--init%%'' flag can be used to [[https://docs.docker.com/reference/cli/docker/container/run/#init|specify an init process]] is used. This causes docker to use [[https://github.com/krallin/tini|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| <code>services: ntfy: image: binwiederhier/ntfy init: true container_name: ntfy </code> ++++ *[[https://blog.phusion.nl/2015/01/20/docker-and-the-pid-1-zombie-reaping-problem/|Docker and the PID 1 zombie reaping problem]] *[[https://github.com/docker-library/official-images?tab=readme-ov-file#init|docker library #init]] *[[https://www.baeldung.com/ops/docker-init-parameter|How to Use –init Parameter in Docker Run Command]] =====References===== *[[https://github.com/just-containers/s6-overlay| 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 *[[https://skarnet.org/software/s6-rc/s6-rc-compile.html|The s6-rc-compile program]] Describes the functionality of the S6-rc system *[[https://forum.level1techs.com/t/easy-to-follow-beginner-guide-on-s6-starter-pack/178411|Easy to follow Beginner Guide on s6 Starter Pack]] It seems that the authors source pages [[https://skarnet.org|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: *[[https://ahmet.im/blog/minimal-init-process-for-containers/|Choosing an init process for multi-process containers]] - Interesting discussion on different init systems, current at that time. (Seems relevant now too.) *[[https://github.com/just-containers/s6-overlay/releases|s6-overlay]] *supervisord: [[http://supervisord.org/|Supervisor: A Process Control System]] *[[https://stackoverflow.com/questions/33117068/use-of-supervisor-in-docker|Use of Supervisor in docker]] <- docker_notes:docker-compose|Back ^ docker_notes:index|Start page ^ docker_notes:docker-reverse-proxy|Next ->