Table of Contents
CMDs6-overlay is an easy-to-install (just extract a tarball or two!) set of scripts and utilities allowing you to use existing Docker images while using s6 as a pid 1 for your container and process supervisor for your services.
Build the following Dockerfile and try it out:
# Use your favorite image
FROM ubuntu
ARG S6_OVERLAY_VERSION=3.2.0.0
RUN apt-get update && apt-get install -y nginx xz-utils
RUN echo "daemon off;" >> /etc/nginx/nginx.conf
CMD ["/usr/sbin/nginx"]
ADD https://github.com/just-containers/s6-overlay/releases/download/v${S6_OVERLAY_VERSION}/s6-overlay-noarch.tar.xz /tmp
RUN tar -C / -Jxpf /tmp/s6-overlay-noarch.tar.xz
ADD https://github.com/just-containers/s6-overlay/releases/download/v${S6_OVERLAY_VERSION}/s6-overlay-x86_64.tar.xz /tmp
RUN tar -C / -Jxpf /tmp/s6-overlay-x86_64.tar.xz
ENTRYPOINT ["/init"]
docker-host $ docker build -t demo .
docker-host $ docker run --name s6demo -d -p 80:80 demo
docker-host $ docker top s6demo acxf
PID TTY STAT TIME COMMAND
11735 ? Ss 0:00 \_ s6-svscan
11772 ? S 0:00 \_ s6-supervise
11773 ? Ss 0:00 | \_ s6-linux-init-s
11771 ? Ss 0:00 \_ rc.init
11812 ? S 0:00 | \_ nginx
11814 ? S 0:00 | \_ nginx
11816 ? S 0:00 | \_ nginx
11813 ? S 0:00 | \_ nginx
11815 ? S 0:00 | \_ nginx
11779 ? S 0:00 \_ s6-supervise
11785 ? Ss 0:00 | \_ s6-ipcserverd
11778 ? S 0:00 \_ s6-supervise
docker-host $ curl --head http://127.0.0.1/
HTTP/1.1 200 OK
Server: nginx/1.18.0 (Ubuntu)
Date: Mon, 17 Jan 2022 13:33:58 GMT
Content-Type: text/html
Content-Length: 612
Last-Modified: Mon, 17 Jan 2022 13:32:11 GMT
Connection: keep-alive
ETag: "61e56fdb-264"
Accept-Ranges: bytes
If you're migrating from a previous version of s6-overlay (v2) to the new version (v3), you may need to make some changes to your services or the way you use s6-overlay in order for everything to work smoothly. This document tries to be accurate on how v3 works, but we have a separate page listing the main differences, and things you're likely to notice. Please read it if you're in this situation!
The project has the following goals:
cont-init.d),
finalization (cont-finish.d) and their own services with dependencies between themPID 1 functionality
s6 and s6-portable-utils. They include handy and composable utilities which make our lives much, much easier.logutil-service which uses s6-log under the hood.USER directive, to run your whole process tree as a specific user. Not compatible with all features, details in the notes section.One of the oft-repeated Docker mantras is "one process per container", but we disagree. There's nothing inherently bad about running multiple processes in a container. The more abstract "one thing per container" is our policy - a container should do one thing, such as "run a chat service" or "run gitlab." This may involve multiple processes, which is fine.
The other reason image authors shy away from process supervisors is they believe a process supervisor must restart failed services, meaning the Docker container will never die.
This does effectively break the Docker ecosystem - most images run one process that will exit when there's an error. By exiting on error, you allow the system administrator to handle failures however they prefer. If your image will never exit, you now need some alternative method of error recovery and failure notification.
Our policy is that if "the thing" fails, then the container should fail, too.
We do this by determining which processes can restart, and which should bring down
the container. For example, if cron or syslog fails, your container can most
likely restart it without any ill effects, but if ejabberd fails, the container
should exit so the system administrator can take action.
Our interpretation of "The Docker Way" is thus:
and our init system is designed to do exactly that. Your images will behave like other Docker images and fit in with the existing ecosystem of images.
See "Writing an optional finish script" under the Usage section for details on stopping "the thing."
Our overlay init is a properly customized one to run appropriately in containerized environments. This section briefly explains how stages work but if you want to know how a complete init system should work, you can read this article: How to run s6-svscan as process 1
/etc/cont-init.d./etc/s6-overlay/s6-rc.d, following dependencies/etc/services.d) to a temporary directory and have s6 start (and supervise) them./etc/cont-finish.d.TERM signal. There should not be any remaining processes anyway.KILL signal. Then the container exits.s6-overlay comes as a set of tarballs that you can extract onto your image. The tarballs you need are a function of the image you use; most people will need the first two, and the other ones are extras you can use at your convenience.
s6-overlay-noarch.tar.xz: this tarball contains the scripts
implementing the overlay. We call it "noarch" because it is architecture-
independent: it only contains scripts and other text files. Everyone who
wants to run s6-overlay needs to extract this tarball.s6-overlay-x86_64.tar.xz: replace x86_64 with your
system's architecture. This tarball contains all the necessary binaries
from the s6 ecosystem, all linked statically and out of the way of
your image's binaries. Unless you know for sure that your image already
comes with all the packages providing the binaries used in the overlay,
you need to extract this tarball.s6-overlay-symlinks-noarch.tar.xz: this tarball contains
symlinks to the s6-overlay scripts so they are accessible via /usr/bin.
It is normally not needed, all the scripts are accessible via the PATH
environment variable, but if you have old user scripts containing
shebangs such as #!/usr/bin/with-contenv, installing these symlinks
will make them work.s6-overlay-symlinks-arch.tar.xz: this tarball contains
symlinks to the binaries from the s6 ecosystem provided by the second
tarball, to make them accessible via /usr/bin. It is normally not
needed, but if you have old user scripts containing shebangs such as
#!/usr/bin/execlineb, installing these symlinks will make them work.syslogd-overlay-noarch.tar.xz: this tarball contains
definitions for a syslogd service. If you are running daemons that
cannot log to stderr to take advantage of the s6 logging infrastructure,
but hardcode the use of the old syslog() mechanism, you can extract
this tarball, and your container will run a lightweight emulation of a
syslogd daemon, so your syslog logs will be caught and stored to disk.To install those tarballs, add lines to your Dockerfile that correspond to the functionality you want to install. For instance, most people would use the following:
ADD https://github.com/just-containers/s6-overlay/releases/download/v${S6_OVERLAY_VERSION}/s6-overlay-noarch.tar.xz /tmp
RUN tar -C / -Jxpf /tmp/s6-overlay-noarch.tar.xz
ADD https://github.com/just-containers/s6-overlay/releases/download/v${S6_OVERLAY_VERSION}/s6-overlay-x86_64.tar.xz /tmp
RUN tar -C / -Jxpf /tmp/s6-overlay-x86_64.tar.xz
Make sure to preserve file permissions when extracting (i.e. to use the
-p option to tar.)
The project is distributed as a set of standard .tar.xz files, which you extract at the root of your image.
(You need the xz-utils package for tar to understand .tar.xz files; it is available
in every distribution, but not always in the default container images, so you may need
to apt install xz-utils or apk add xz, or equivalent, before you can
expand the archives.)
Afterwards, set your ENTRYPOINT to /init.
Right now, we recommend using Docker's ADD directive instead of running wget or curl
in a RUN directive - Docker is able to handle the https URL when you use ADD, whereas
your base image might not be able to use https, or might not even have wget or curl
installed at all.
From there, you have a couple of options:
CMD.CMDUsing CMD is a convenient way to take advantage of the overlay. Your CMD can be given at
build time in the Dockerfile, or at run time on the command line, either way is fine. It will
be run as a normal process in the environment set up by s6; when it fails or exits, the
container will shut down cleanly and exit. You can run interactive programs in this manner:
only the CMD will receive your interactive command, the support processes will be unimpacted.
For example:
FROM busybox
ADD https://github.com/just-containers/s6-overlay/releases/download/v${S6_OVERLAY_VERSION}/s6-overlay-noarch.tar.xz /tmp
RUN tar -C / -Jxpf /tmp/s6-overlay-noarch.tar.xz
ADD https://github.com/just-containers/s6-overlay/releases/download/v${S6_OVERLAY_VERSION}/s6-overlay-x86_64.tar.xz /tmp
RUN tar -C / -Jxpf /tmp/s6-overlay-x86_64.tar.xz
ENTRYPOINT ["/init"]
docker-host $ docker build -t s6demo .
docker-host $ docker run -ti s6demo /bin/sh
/package/admin/s6-overlay/libexec/preinit: notice: /var/run is not a symlink to /run, fixing it
s6-rc: info: service s6rc-oneshot-runner: starting
s6-rc: info: service s6rc-oneshot-runner successfully started
s6-rc: info: service fix-attrs: starting
s6-rc: info: service fix-attrs successfully started
s6-rc: info: service legacy-cont-init: starting
s6-rc: info: service legacy-cont-init successfully started
s6-rc: info: service legacy-services: starting
s6-rc: info: service legacy-services successfully started
/ # ps
PID USER TIME COMMAND
1 root 0:00 /package/admin/s6/command/s6-svscan -d4 -- /run/service
17 root 0:00 {rc.init} /bin/sh -e /run/s6/basedir/scripts/rc.init top /bin/sh
18 root 0:00 s6-supervise s6-linux-init-shutdownd
20 root 0:00 /package/admin/s6-linux-init/command/s6-linux-init-shutdownd -c /run/s6/basedir -g 3000 -C -B
24 root 0:00 s6-supervise s6rc-fdholder
25 root 0:00 s6-supervise s6rc-oneshot-runner
31 root 0:00 /package/admin/s6/command/s6-ipcserverd -1 -- /package/admin/s6/command/s6-ipcserver-access -v0 -E -l0 -i data/rules -- /packa
58 root 0:00 /bin/sh
66 root 0:00 ps
/ # exit
s6-rc: info: service legacy-services: stopping
s6-rc: info: service legacy-services successfully stopped
s6-rc: info: service legacy-cont-init: stopping
s6-rc: info: service legacy-cont-init successfully stopped
s6-rc: info: service fix-attrs: stopping
s6-rc: info: service fix-attrs successfully stopped
s6-rc: info: service s6rc-oneshot-runner: stopping
s6-rc: info: service s6rc-oneshot-runner successfully stopped
docker-host $


免费创建高清无水印Sora视频
Vora是一个免费创建高清无水印Sora视频的AI工具


最适合小白的AI自动化工作流平台
无需编码,轻松生成可复用、可变现的AI自动化工作流

大模型驱动的Excel数据处理工具
基于大模型交互的表格处理系统,允许 用户通过对话方式完成数据整理和可视化分析。系统采用机器学习算法解析用户指令,自动执行排序、公式计算和数据透视等操作,支持多种文件格式导入导出。数据处理响应速度保持在0.8秒以内,支持超过100万行数据的即时分析。


AI辅助编程,代码自动修复
Trae是一种自适应的集成开发环境(IDE),通过自动化和多元协作改变开发流程。利用Trae,团队能够更快速、精确地编写和部署代码,从而提高编程效率和项目交付速度。Trae具备上下文感知和代码自动完成功能,是提升开发效率的理想工具。


AI论文写作指导平台
AIWritePaper论文写作是一站式AI论文写作辅助工具,简化了选题、文献检索至论文撰写的整个过程。通过简单设定,平台可快速生成高质量论文大纲和全文,配合图表、参考文献等一应俱全,同时提供开题报告和答辩PPT等增值服务,保障数据安全,有效提升写作效率和论文质量。


AI一键生成PPT,就用博思AIPPT!
博思AIPPT,新一代的AI生成PPT平台,支持智能生成PPT、AI美化PPT、文本&链接生成PPT、导入Word/PDF/Markdown文档生成PPT等,内置海量精美PPT模板,涵盖商务、教育、科技等不同风格,同时针对每个页面提供多种版式,一键自适应切换,完美适配各种办公场景。


AI赋能电商视觉革命,一站式智能商拍平台
潮际好麦深耕服装行业,是国内AI试衣效果最好的软件。使用先进AIGC能力为电商卖家批量提供优质的、低成本的商拍图。合作品牌有Shein、Lazada、安踏、百丽等65个国内外头部品牌,以及国内10万+淘宝、天猫、京东等主流平台的品牌商家,为卖家节省将近85%的出图成本,提升约3倍出图效率,让品牌能够快速上架。


企业专属的AI法律顾问
iTerms是法大大集团旗下法律子品牌,基于最先进的大语言模型(LLM)、专业的法律知识库和强大的智能体架构,帮助企业扫清合规障碍,筑牢风控防线,成为您企业专属的AI法律顾问。


稳定高效的流量提升解决方案,助力品牌曝光
稳定高效的流量提升解决方案,助力品牌曝光


最新版Sora2模型免费使用,一键生成无水印视频
最新版Sora2模型免费使用,一键生成无水印视频
最新AI工具、AI资讯
独家AI资源、AI项目落地

微信扫一扫关注公众号