Sign inSign up

braindoctor/s6-openshift

By braindoctor

•Updated over 8 years ago

A base image to run multi-process containers supervised by s6 (UNMAINTAINED)

Image
0

981

braindoctor/s6-openshift repository overview

⁠s6-openshift

A base image to run multi-process containers supervised by the lightweight s6 process supervisor.

This image should run normally on docker, but it also does on openshift (arbitrary user id).

⁠How to use

⁠Create Services

Let's say, that you have an application that runs a Java backend and an nginx frontend webserver. You want to run this application in a single container for whatever reason. For this to work you need a process supervisor, such as supervisord or s6.

This base image has an ONBUILD command that copies your local s6 folder into the new container right after you declare FROM ....

  1. Create a directory named s6 in your docker repo.
  2. For each service, create a subdirectory with the service name as directory name.
  3. For each service, write a run script that goes into the aforementioned subdirectory.

For more detailed s6 instructions, go to https://skarnet.org/software/s6/servicedir.html⁠

⁠Example

This is the nginx run script. It will get copied to /etc/services.d/nginx on the container, but the ONBUILD instruction will take care of that. The script should never terminate.

# cat s6/nginx/run

#!/bin/sh

echo "${PWD}" # beware that this will be /etc/services.d/nginx, you may want to "cd /..." first.
echo "[s6] Starting: nginx"
exec nginx -g "daemon off;" # be sure to use "exec"

Similarly, here is a sample config for the java file.

# cat s6/java/run

#!/bin/sh

echo "${PWD}"
echo "[s6] Starting: java"
exec java -jar yourapp.jar
⁠Terminate on failure

By default, s6 will restart the run scripts if they exited. This can be undesired since a container should stop if there are problems. Otherwise a non-working container might not get detected by a sysadmin. In our example, it is fine to restart the nginx server if it crashes, but when tha java process exits, we want to shutdown the container. This can be achieved with a finish script.

# cat s6/java/finish

#!/bin/sh

echo "[s6] Finishing: java"
# do cleanup...
 
# use this command to shut down the container.
s6-svscanctl -q /etc/services.d

⁠Image Variants

  • latest: Latest Alpine Linux
⁠Alpine
  • alpine-3.7: Alpine 3.7

Tag summary

Content type

Image

Digest

Size

3.2 MB

Last updated

over 8 years ago

docker pull braindoctor/s6-openshift