Sign inSign up

wickedmonkey/base-image

By wickedmonkey

•Updated over 11 years ago

Image
1

190

wickedmonkey/base-image repository overview

⁠alpine-base

A base image for running just about anything within a container, based on Alpine Linux 3.1.

⁠Process management

This image includes s6⁠ (via s6-overlay⁠), to make it super simple to start multiple process and manage them correctly.

Aren't you only supposed to run one process per container? Well yes and no... the following are good examples of when multiple processes within one container might be necessary:

  • automatically updating nginx⁠ proxy settings when a down-stream application server (nodejs, php, etc) restarts (and the IP changes)
  • automatically updating HAProxy⁠ configuration to load balance to a group of down-stream application servers
  • running a logging daemon to centralize log management (i.e. logentries⁠, loggly⁠, logstash⁠)
  • when you need to run a script on application server crash (to tidy something up), as the standard Docker container restart policies⁠ won't provide this

⁠Usage

To use this image include FROM smebberson/alpine-base at the top of your Dockerfile. Starting from smebberson/alpine-base provides you with the ability to easily start any service using s6. s6 will also keep it running for you, restarting it when it crashes.

To start your service using s6:

  • create a folder at /etc/services.d/service-name
  • create a file in your new folder called run and give it execute permissions
  • inside that file start your service, for example:
#!/usr/bin/env bash

# start nginx
exec nginx;
⁠Finish scripts

If you want to run a script when your application stops, simply:

  • create a file in your /etc/services.d/service-name folder called finish and give it execute permissions

In this file, do whatever you need to, but keep it quick and simple (anything over 3 seconds and s6 will force quit it). Once this script has run, s6 will call /etc/services.d/service-name/run again to restart your service.

There is also further information about how to use CMD⁠ with s6-overlay.

⁠Crashes, logs, no-restarts?

s6 has a number of other options⁠ that you can use to customise what happens when your process suddenly dies. s6-overlay⁠ also has a guide to customising s6⁠ (when using s6-overlay⁠).

⁠Examples

An example of using this image can be found in the smebberson/nodejs⁠ Dockerfile⁠.

Tag summary

Content type

Image

Digest

sha256:794f4e5bb…

Size

5 MB

Last updated

over 11 years ago

docker pull wickedmonkey/base-image