Alpine Linux providing s6 init system
4.5K
Provides s6 init system via s6-overlay including what has been provided from robwdux/alpine-base
3 Stage Init system
Stage 1: s6-init setup
Stage 2:
Stage 3: container shutdown - execute code prior to service(s) being stopped
Reaps defunct (zombie) processes, mitigating full process table
FROM robwdux/alpine-init
Processes should not daemonize, but run in foreground under supervision of the init system
Processes should log to standard error and standard out
Leverage the docker log driver to stream logs off the host without incurring the i/o hit on disk.
Interactively test commands and such then record in a Dockerfile for a new project
# add short alias for docker-compose
echo "alias dc='docker-compose '" >> ~/.bashrc && source ~/.bashrc
# the repo
git clone https://github.com/robwdux/docker-alpine-init.git
cd docker-alpine-init/
# build and run (image doesn't exist locally)
dc run --rm -ti init bash
# build explicitly
dc build
# build with meta data via build args for git info
sudo ./build.sh
# view meta data
$ docker inspect --format '{{ json .Config.Labels }}' robwdux/alpine-init:1.18.3.1 | jq
sudo docker run --rm -it \
--name init \
robwdux/docker-alpine-init \
bash
sudo docker run -d \
--name init \
robwdux/docker-alpine-init \
ping 8.8.8.8 && \
sudo docker exec -it init bash
# in container
bash-4.3# ps
PID USER TIME COMMAND
1 root 0:00 s6-svscan -t0 /var/run/s6/services
21 root 0:00 foreground if /etc/s6/init/init-stage2-redirfd foreground if if s6-echo -n -- [s6-init] making
22 root 0:00 s6-supervise s6-fdholderd
26 root 0:00 foreground s6-setsid -gq -- with-contenv ping 8.8.8.8 import -u ? if s6-echo -- ping exited ${?} foreground redirfd
99 root 0:00 /bin/busybox ping 8.8.8.8
100 root 0:00 bash
106 root 0:00 ps
bash-4.3# ps -o user,group,comm,pid,ppid
USER GROUP COMMAND PID PPID
root root s6-svscan 1 0
root root foreground 21 1
root root s6-supervise 22 1
root root foreground 26 21
root root busybox 99 26
root root bash 100 0
root root ps 105 100
Content type
Image
Digest
sha256:e10cac20f…
Size
5 MB
Last updated
over 10 years ago
docker pull robwdux/docker-alpine-init