Bicti, efficient startup script for within docker containers
Simple startup tool for docker containers.
bicti is intended as the entrypoint of a container, and provides a few helpers for systems that may require several services (for instance, fastcgi and nginx and cron and logrotate).
Its features include:
Declarative list of supported commands
Launch all demons or only a few ones
Drop into a shell instead
bicti is written in Python; it supports all versions from 2.6 onwards. It also relies on runit (http://smarden.org/runit/) for daemon management.
In your dockerfile, add:
RUN apt-get -qqy install runit python python-pip RUN pip install bicti && ln -s /sbin/bicti `which bicti` ADD ./bicti.ini /etc/bicti.ini RUN /sbin/bicti --setup ENTRYPOINT "/sbin/bicti"
Retrieve bicti and its dependencies
Load your bicti.ini configuration file (expected at /etc/bicti.ini)
Setup all daemon startup scripts in /etc/runit
Declare bicti as your entry point.
Beyond a few command-line flags, most of bicti’s job is in setting up the configuration for runit.
Upon startup, bicti will:
Load its configuration file (/etc/bicti.ini)
Setup runit to start the declared services
Transfer control to runit, which handles daemon auto-restart, orphan process reaping, etc.
$ docker run my/image --help usage: bicti.py [--config CONFIG] [--root ROOT] [-h] [--setup] [--shell [SHELL]] [--all] [SERVICE [SERVICE ...]] Bicti, the docker inner setup. positional arguments: SERVICE Services to start (valid options: cron,uwsgi) optional arguments: --config CONFIG, -c CONFIG Read configuration from CONFIG --root ROOT Use paths relative to ROOT -h, --help Show this help message and exit --setup Setup the service files --shell [SHELL] Drop to a shell (default=/bin/bash) --all Start all services
[bicti] ; Run before any service is started setup = <s>/sbin/my-image-setup</s> ; Run once all services have been stopped teardown = <s>/sbin/my-image-cleanup</s> ; One section per service [cron] ; Actual command to run command = <s>/usr/bin/cron</s> ; Require another service to be started first after = <s>syslog</s> [uwsgi] command = <s>/usr/bin/uwsgi</s> ; Command to run before starting the service setup_command = <s>mkdir /var/log/uwsgi</s> ; Special uid/gid uid = <s>www-data</s> gid = <s>www-data</s>
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.