Skip to content

Commit

Permalink
Fix terminal management with latest s6-l-i, version: 3.1.5.0
Browse files Browse the repository at this point in the history
Also add S6_CMD_USE_TERMINAL to make use of the new fix.

Signed-off-by: Laurent Bercot <ska@appnovation.com>
  • Loading branch information
skarnet committed May 4, 2023
1 parent 6390cce commit 9eda003
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 8 deletions.
13 changes: 9 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ Build the following Dockerfile and try it out:
```
# Use your favorite image
FROM ubuntu
ARG S6_OVERLAY_VERSION=3.1.4.1
ARG S6_OVERLAY_VERSION=3.1.5.0
RUN apt-get update && apt-get install -y nginx xz-utils
RUN echo "daemon off;" >> /etc/nginx/nginx.conf
Expand Down Expand Up @@ -847,7 +847,12 @@ with the rest of the shutdown.
the shutdown procedure when all the processes have received a TERM signal, for them to die
before sending a `KILL` signal to make *sure* they're dead.
* `S6_LOGGING_SCRIPT` (default = "n20 s1000000 T"): This env decides what to log and how, by default every line will prepend with ISO8601, rotated when the current logging file reaches 1mb and archived, at most, with 20 files.
* `S6_CMD_ARG0` (default = not set): Value of this env var will be prepended to any `CMD` args passed by docker. Use it if you are migrting an existing image to a s6-overlay and want to make it a drop-in replacement, then setting this variable to a value of previously used ENTRYPOINT will improve compatibility with the way image is used.
* `S6_CMD_ARG0` (default = not set): Value of this env var will be prepended to any `CMD` args passed by docker. Use it if you are migrating an existing image to s6-overlay and want to make it a drop-in replacement: setting this variable to the value of a previously used ENTRYPOINT will help you transition.
* `S6_CMD_USE_TERMINAL` (default = 0): Set this value to **1** if you have a CMD that needs a terminal for its output
(typically when you're running your container with `docker run -it`), and you have set `S6_LOGGING` to a nonzero value.
This setting will make your CMD actually output to your terminal; the drawback is that its output will not be logged.
By default (when this variable is **0** or not set), the stdout and stderr of your CMD are logged when `S6_LOGGING` is nonzero,
which means they go to a pipe even if you're running it in an interactive terminal.
* `S6_FIX_ATTRS_HIDDEN` (default = 0): Controls how `fix-attrs.d` scripts process files and directories.
* **`0`**: Hidden files and directories are excluded.
* **`1`**: All files and directories are processed.
Expand All @@ -863,7 +868,7 @@ Note that this value also includes the time setting up legacy container initiali
and that it is taken into account even if you are not running a CMD. In other words: no matter whether you're running a CMD or not,
if you have scripts in `/etc/cont-init.d` that take a long time to run, you should set this variable to either 0, or a value high
enough so that your scripts have time to finish without s6-overlay interrupting them and diagnosing an error.
* `S6_READ_ONLY_ROOT` (default = 0): When running in a container whose root filesystem is read-only, set this env to **1** to inform init stage 2 that it should copy user-provided initialization scripts from `/etc` to `/var/run/s6/etc` before it attempts to change permissions, etc. See [Read-Only Root Filesystem](#read-only-root-filesystem) for more information.
* `S6_READ_ONLY_ROOT` (default = 0): When running in a container whose root filesystem is read-only, set this env to **1** to inform init stage 2 that it should copy user-provided initialization scripts from `/etc` to `/run/s6/etc` before it attempts to change permissions, etc. See [Read-Only Root Filesystem](#read-only-root-filesystem) for more information.
* `S6_SYNC_DISKS` (default = 0): Set this env to **1** to inform init stage 3 that it should attempt to sync filesystems before stopping the container. Note: this will likely sync all filesystems on the host.
* `S6_STAGE2_HOOK` (default = none): If this variable exists, its contents
will be interpreted as a shell excerpt that will be run in the early stage 2,
Expand Down Expand Up @@ -941,7 +946,7 @@ RUN cd /tmp && sha256sum -c *.sha256

### `USER` directive

As of version 3.1.4.1, s6-overlay has limited support for running as a user other than `root`:
As of version 3.1.5.0, s6-overlay has limited support for running as a user other than `root`:

* Tools like `fix-attrs` and `logutil-service` are unlikely to work (they rely
on being able to change UIDs).
Expand Down
4 changes: 2 additions & 2 deletions conf/defaults.mk
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# e.g.: make SHEBANGDIR=/usr/bin VERSION=3.1.4.0

# The version of the software being built.
VERSION := 3.1.4.2
VERSION := 3.1.5.0

# Where stuff is going to be built. Change for out-of-tree builds.
OUTPUT := output
Expand All @@ -21,7 +21,7 @@ TOOLCHAIN_PATH :=

# When fetching one from the web, what version we want.
# Only a few versions are available, don't change blindly.
TOOLCHAIN_VERSION := 12.2.0
TOOLCHAIN_VERSION := 13.1.0

# For fetching toolchains: the download command.
# Change to curl -O if you don't have wget.
Expand Down
4 changes: 2 additions & 2 deletions conf/versions
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ S6_VERSION=v2.11.3.2
# S6_RC_VERSION=58f93f6c710cc88acfa721a45efc1f64dfc557df
S6_RC_VERSION=v0.5.4.1

# S6_LINUX_INIT_VERSION=b5ed0d1ef886d3c12345c22e6e42aa5fca272bb4
S6_LINUX_INIT_VERSION=v1.1.1.0
# S6_LINUX_INIT_VERSION=3be1f17208a1e3d48c1c0607bff50402bc45ceb3
S6_LINUX_INIT_VERSION=v1.1.1.1

# S6_PORTABLE_UTILS_VERSION=a80a1304ff86b8cf493265696d517aea2cf7a703
S6_PORTABLE_UTILS_VERSION=v2.3.0.2
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
#!/bin/sh -e

# This is stage 2, the part of the initialization that is run once
# the s6 supervision tree has been set up. This is where all the
# services are brought up, and the CMD, if any, is run.

trap : INT # guard against ^C as much as possible

prog=/run/s6/basedir/scripts/rc.init
Expand Down Expand Up @@ -58,6 +62,9 @@ if test "$#" -gt 0 ; then
cd `s6-cat < /run/s6/workdir`
set +e
arg0=`printcontenv S6_CMD_ARG0`
if b=`printcontenv S6_CMD_USE_TERMINAL` && eltest "$b" =~ '^[[:digit:]]+$' -a "$b" -gt 0 && b=`tty` ; then
arg0="redirfd -w 1 $b fdmove -c 2 1 $arg0"
fi
if b=`printcontenv S6_CMD_RECEIVE_SIGNALS` && eltest "$b" =~ '^[[:digit:]]+$' -a "$b" -gt 0 ; then
$arg0 "$@" &
cmdpid="$!"
Expand Down

0 comments on commit 9eda003

Please sign in to comment.