Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
docker_notes:init [2024-08-24 Sat wk34 21:33] – [s6 commands] baumkpdocker_notes:init [2025-06-22 Sun wk25 14:58] (current) – [References] baumkp
Line 1: Line 1:
-{{tag>Alpine linux docker init s6 s6-rc}}+{{tag>Alpine linux docker init s6 s6-rc alias}}
 ======Docker init Systems====== ======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. +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.\\   
 +++++tldr;
 +There is a lot of argument in the init world, SystemD seems to have taken over the init system in most "modern" Linux distributions.  It seems to break the Unix philosophy of do one thing well, and does many things, although it is broken into modules.  Perhaps more concerning is when graphical / windowing systems such as Gnome rely upon SystemD calls making it break with other init systems.\\ 
 +Some Unix (Linux focus) init systems: 
 +  *sysv (System V) 
 +    *[[https://www.kernel.org/doc/html/v6.14-rc4/filesystems/sysv-fs.html|SystemV Filesystem]] 
 +    *[[https://docs.redhat.com/en/documentation/red_hat_enterprise_linux/4/html/reference_guide/s1-boot-init-shutdown-sysv|SysV Init Runlevels]] 
 +  *[[https://systemd.io/|SystemD]] 
 +  *[[https://wiki.gentoo.org/wiki/OpenRC|OpenRC]] 
 +  *[[http://smarden.org/runit/|runit]] 
 +  *[[https://skarnet.org/software/s6/|s6]] 
 +  *And arguably not a full init systems: 
 +    *[[https://supervisord.org/|supervisord]] 
 +    *[[http://cr.yp.to/daemontools.html|daemontools]] 
 +    ***launchd** is the process control system system used by Apple Max OS X, perhaps inspiration for systemd? 
 +Some references (just do an online search....): 
 +  *[[https://www.tecmint.com/best-linux-init-systems/|6 Best Modern Linux ‘init’ Systems (1992-2023)]] 
 +  *[[https://www.hackerstack.org/linux-system-v-init-and-systemd-essentials/|Linux SysV init and Systemd essentials]]
 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: 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-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-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)]]   *[[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)+  *mailserver
     *[[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#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#mariadb|Mail server database and web interface (mariadb php nginx)]]
Line 16: Line 32:
  
 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.  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===== =====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. 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.
Line 77: Line 93:
 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 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]]
 +
 +=====alias in S6 init=====
 +I like the alias command to change some default CLI command flags, in particular ls => ls -la, which I normally call ll.  I had no success using the alias command in S6 init scripts. I found the following solution, by using the s6 pre_start_script to add a link ''ll.sh'' script in to the ''/bin'' directory.
 +
 +<code bash>#get my favourite alias working in Alpine sh has been a pain
 +/bin/ln -s /app/scripts/ll.sh /bin/ll</code>
 +
 +Where ''ll.sh'' is:
 +<code bash>#!/bin/sh
 +exec ls -la "$@"</code>
 =====References===== =====References=====
-  *[[https://github.com/just-containers/s6-overlay| just-containers/s6-overlay]] (**Version 3.2.0.0** as of 2024-06-29, last checked 2024-07-27), note only a minor change since previous version+  *[[https://github.com/just-containers/s6-overlay| just-containers/s6-overlay]] (**Version 3.2.1.0** as of 2025-05-07, last checked 2025-06-22), 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://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]]   *[[https://forum.level1techs.com/t/easy-to-follow-beginner-guide-on-s6-starter-pack/178411|Easy to follow Beginner Guide on s6 Starter Pack]]