{"id":28958770,"url":"https://github.com/ericwq/s6","last_synced_at":"2026-02-07T11:31:43.006Z","repository":{"id":161987095,"uuid":"636500633","full_name":"ericwq/s6","owner":"ericwq","description":"docker image with s6-overlay or openrc as init system.","archived":false,"fork":false,"pushed_at":"2023-05-30T01:17:32.000Z","size":47,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-07-23T12:20:33.164Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Dockerfile","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"cc0-1.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ericwq.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2023-05-05T01:49:37.000Z","updated_at":"2023-05-14T06:33:17.000Z","dependencies_parsed_at":null,"dependency_job_id":"d4424eb3-3a9e-47ee-936d-8d6a1db3d64a","html_url":"https://github.com/ericwq/s6","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/ericwq/s6","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ericwq%2Fs6","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ericwq%2Fs6/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ericwq%2Fs6/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ericwq%2Fs6/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ericwq","download_url":"https://codeload.github.com/ericwq/s6/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ericwq%2Fs6/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29193582,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-07T07:37:03.739Z","status":"ssl_error","status_checked_at":"2026-02-07T07:37:03.029Z","response_time":63,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-06-23T23:07:05.431Z","updated_at":"2026-02-07T11:31:43.001Z","avatar_url":"https://github.com/ericwq.png","language":"Dockerfile","funding_links":[],"categories":[],"sub_categories":[],"readme":"# alpine container with s6-rc or openrc support\n\nThis is an alpine container which suppport [s6](https://skarnet.org/software/s6/) or [openrc](https://github.com/OpenRC/openrc) as init system. The container need [utmps](https://git.skarnet.org/cgi-bin/cgit.cgi/utmps/about/) service and  [ssh](https://www.openssh.com/) service. The sshd service is used to support remote login. The utmps services is used to support `last` and `who` command.\n\nI came cross s6 because `utmps` need a process supervisor. `utmps` is required because default alpine doesn't support [utmpx.h API](http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/utmpx.h.html). I tried `s6` first, after several days study, it turns out to be that [s6-rc](https://skarnet.org/software/s6-rc/index.html) and [s6-overlay](https://github.com/just-containers/s6-overlay) is what I need for container. With the help from [utmps document](https://git.skarnet.org/cgi-bin/cgit.cgi/utmps/tree/examples/s6-rc), I built a `s6-rc` container for `utmps`. Eventually, s6-rc container has all the required packages, except the utmps init script. That means the container cant't support `last` and `who` command, even if the container has all the necessary services.\n\n`openrc` is the next effort. Got a clue from this [post](https://gitlab.alpinelinux.org/alpine/aports/-/issues/13659). Then a [dockerfile](https://github.com/dockage/alpine/blob/main/3.17/Dockerfile) in github.com help me to build the `openrc` container. This time the container can support `last` and `who` command.\n\nCompare s6-rc container and openrc container, `utmps-openrc` package is the key to provide init script for openrc container. Maybe you can find the solution from the `utmps-openrc` package. The following is the content of `utmps-openrc`:\n\n\u003cdetails\u003e\u003csummary\u003eutmps-openrc package\u003c/summary\u003e\u003cp\u003e\n\n```sh\nopenrc-ssh:/etc/init.d# apk info -a utmps-openrc\nutmps-openrc-0.1.2.1-r1 description:\nA secure utmp/wtmp implementation (OpenRC init scripts)\n\nutmps-openrc-0.1.2.1-r1 webpage:\nhttps://skarnet.org/software/utmps/\n\nutmps-openrc-0.1.2.1-r1 installed size:\n32 KiB\n\nutmps-openrc-0.1.2.1-r1 depends on:\n\nutmps-openrc-0.1.2.1-r1 provides:\n\nutmps-openrc-0.1.2.1-r1 is required by:\n\nutmps-openrc-0.1.2.1-r1 contains:\netc/init.d/btmpd\netc/init.d/utmp-init\netc/init.d/utmp-prepare\netc/init.d/utmpd\netc/init.d/wtmpd\n\nutmps-openrc-0.1.2.1-r1 triggers:\n\nutmps-openrc-0.1.2.1-r1 has auto-install rule:\nopenrc\nutmps=0.1.2.1-r1\n\nutmps-openrc-0.1.2.1-r1 affects auto-installation of:\n\nutmps-openrc-0.1.2.1-r1 replaces:\n\nutmps-openrc-0.1.2.1-r1 license:\nISC\n```\n\n\u003c/p\u003e\u003c/details\u003e\n\nIf you check the `utmps-openrc` package, you will find the `utmp-init`, `utmp-prepare` script.\n\nI don't have enough time to research all available init system. There is some articles to compare the init systems: \n- [A new service manager for Linux distributions](https://skarnet.com/projects/service-manager.html)\n- [Why another supervision suite ?](https://skarnet.org/software/s6/why.html)\n- [Why s6-rc ?](https://skarnet.org/software/s6-rc/why.html)\n- [Comparison of init systems](https://wiki.gentoo.org/wiki/Comparison_of_init_systems)\n- [systemd bad for dev and gentoo?](https://forums.gentoo.org/viewtopic-t-994548.html).\n\n## openrc container\n\nThis container use `openrc` as the init system. It also support utmpd, wtmpd and sshd service on boot.\n\n### usage\n\nRun the following command to build the openrc container. Check [here](https://github.com/ericwq/nvide#build-and-run-the-sshmosh-image) if you don't understand hwo to generate `~/.ssh/id_rsa.pub` file.\n\n```sh\n% docker build --build-arg ROOT_PWD=passowrd \\\n\t--build-arg USER_PWD=password \\\n\t--build-arg SSH_PUB_KEY=\"$(cat ~/.ssh/id_rsa.pub)\" \\\n\t--progress plain -t openrc-ssh:0.1.0 -f openrc.dockerfile .\n```\n\nRun the following command to start the container.\n\n```sh\n% docker run --env TZ=Asia/Shanghai --tty --privileged --volume /sys/fs/cgroup:/sys/fs/cgroup:ro \\\n  -h openrc-ssh --name openrc-ssh -d -p 5022:22 openrc-ssh:0.1.0\n```\n\nRun the following command to login in to the container.\n\n```sh\n% rm ~/.ssh/known_hosts ~/.ssh/known_hosts.old\n% ssh -p 5022 root@localhost\n```\n\nLogin in to the container and run `setup-utmp` init script for utmps. unfortunately I can't find the right way to run `setup-utmp` at building image time.\n\n```sh\n% setup-utmp\n```\n\n~~Finally, you need to reboot the container and login in again.~~ Now you can run `who` and `last` command.\n\n```sh\nopenrc-ssh:/etc/init.d# who\nroot            pts/1           00:00   May 13 18:46:42  172.17.0.1\nopenrc-ssh:/etc/init.d# last\nUSER       TTY            HOST               LOGIN        TIME\nide        pts/2          172.17.0.1         May 13 18:47\nroot       pts/1          172.17.0.1         May 13 18:46\nreboot     system boot    5.15.49-linuxkit   May 13 18:47\n```\n\nYou can check the init system and required services with the following command.\n\n```sh\nopenrc-ssh:/etc/init.d# pstree -p\ninit(1)-+-s6-ipcserverd(154)\n        |-s6-ipcserverd(217)\n        |-s6-ipcserverd(245)\n        `-sshd(190)---sshd(286)---ash(288)---pstree(338)\n```\n\n## s6-rc container\n\n### usage\n\ncheck the `build.md` for how to build image and run container.\n\n### the relationship between s6 and s6-overlay\n\n`s6` is the base, it is best used in virtual machine environment instead of docker container. `s6-overlay` is the `s6` wrapper for docker container environment.\n\n### installation via package or tar ball\n\nAlpine and other linux distribution support `s6` related package. For example, on alpine there are full set of `s6` package available.\n\n\u003cdetails\u003e\u003csummary\u003es6 related package in alpine\u003c/summary\u003e\u003cp\u003e\n\n```sh\n# apk search s6\ns6-portable-utils-2.3.0.2-r1\ns6-networking-2.5.1.3-r1\ns6-2.11.3.2-r1\ns6-rc-0.5.4.1-r1\ns6-dns-doc-2.3.5.5-r1\ns6-dns-2.3.5.5-r1\ns6-dns-dev-2.3.5.5-r1\ns6-ipcserver-2.11.3.2-r1\ns6-portable-utils-doc-2.3.0.2-r1\ns6-linux-utils-2.6.1.2-r1\ns6-networking-man-pages-2.5.1.3.3-r0\ns6-overlay-helpers-0.1.0.1-r0\ns6-linux-init-static-1.1.1.1-r0\ns6-openrc-2.11.3.2-r1\ns6-linux-init-1.1.1.1-r0\ns6-rc-doc-0.5.4.1-r1\ns6-networking-dev-2.5.1.3-r1\ns6-dns-static-2.3.5.5-r1\ns6-overlay-doc-3.1.5.0-r0\ns6-dev-2.11.3.2-r1\ns6-overlay-3.1.5.0-r0\ns6-doc-2.11.3.2-r1\ns6-static-2.11.3.2-r1\ns6-linux-init-doc-1.1.1.1-r0\ns6-linux-utils-doc-2.6.1.2-r1\ns6-networking-static-2.5.1.3-r1\ns6-man-pages-2.11.3.2.4-r0\ns6-rc-static-0.5.4.1-r1\ns6-overlay-syslogd-3.1.5.0-r0\ns6-rc-man-pages-0.5.4.1.2-r0\ns6-linux-init-man-pages-1.1.1.0.1-r0\ns6-portable-utils-man-pages-2.3.0.2.2-r0\ns6-rc-dev-0.5.4.1-r1\ns6-linux-init-dev-1.1.1.1-r0\ns6-networking-doc-2.5.1.3-r1\n```\n\n\u003c/p\u003e\u003c/details\u003e\n\nWhile the origianl `s6-overlay` site suggest `tar.xz` installation. Such as:\n\n```dockerfile\n# extract s6-overlay\n#\nADD https://github.com/just-containers/s6-overlay/releases/download/v${S6_OVERLAY_VERSION}/s6-overlay-noarch.tar.xz /tmp/s6/\nRUN tar xf /tmp/s6/s6-overlay-noarch.tar.xz -C /\nADD https://github.com/just-containers/s6-overlay/releases/download/v${S6_OVERLAY_VERSION}/s6-overlay-x86_64.tar.xz /tmp/s6/\nRUN tar xf /tmp/s6/s6-overlay-x86_64.tar.xz -C /\nRUN rm -rf /tmp/s6\n```\nFor alpine, `s6-overlay` package is more convinient for us. The following docker command is much more simple.\n\n```dockerfile\nRUN apk add --no-cache --update openssh-server s6-overlay\n```\n\n### sshd problem\n\n`s6-overlay` support running `sshd` as supervised process in the follwoing way. In this way, the container will execute `ENTRYPOINT` first, then the system will execute `CMD` part.\n\n```dockerfile\nCMD [\"/usr/sbin/sshd\", \"-D\"]\n\n# start s6-overlay\n#\nENTRYPOINT [\"/init\"]\n```\n\n### PATH problem\n\nWith the tar ball installation, the `s6-overlay` is installed under `/command` and `/package` directory. utmps give an example `s6-rc` configuration. You need to change shebangs line to respect the above installation.\n\nThe origianl content of `utmpd/run` script:\n\n```sh\n#!/bin/execlineb -P\n\nfdmove -c 2 1\ns6-setuidgid utmp\ncd /run/utmps\nfdmove 1 3\ns6-ipcserver -1 -- /run/utmps/utmpd-socket\nutmps-utmpd\n```\nThe modified content of `utmpd/run` script, keep your eye on the first shebangs line. Without the modification, your run script is not executeable.\n\n```sh\n#!/command/execlineb -P\n\nfdmove -c 2 1\ns6-setuidgid utmp\ncd /run/utmps\nfdmove 1 3\ns6-ipcserver -1 -- /run/utmps/utmpd-socket\nutmps-utmpd\n```\n### reference\n\n- [s6-example](https://github.com/beldpro-ci/s6-entrypoint)\n- [Docker and S6 – My New Favorite Process Supervisor](https://tutumcloud.wordpress.com/2014/12/02/docker-and-s6-my-new-favorite-process-supervisor/)\n- [Building a skarnet.org s6 Init System](https://danmc.net/posts/s6-1/)\n- [Quickstart and FAQ for s6-linux-init](http://skarnet.org/software/s6-linux-init/quickstart.html)\n- [An overview of s6](https://skarnet.org/software/s6/overview.html)\n- [s6 overlay](https://github.com/just-containers/s6-overlay)\n- [S6 Made Easy, with the S6 Overlay](https://tutumcloud.wordpress.com/2015/05/20/s6-made-easy-with-the-s6-overlay/)\n- [How to understand S6 Overlay v3](https://darkghosthunter.medium.com/how-to-understand-s6-overlay-v3-95c81c04f075)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fericwq%2Fs6","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fericwq%2Fs6","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fericwq%2Fs6/lists"}