跳转到主要内容

Bicti,Docker容器内高效的启动脚本

项目描述

简单的Docker容器启动工具。

bicti旨在作为容器的入口点,并为可能需要多个服务(例如,fastcgi和nginx和cron和logrotate)的系统提供一些辅助工具。

其功能包括

  • 支持命令的声明性列表

  • 启动所有守护进程或仅启动几个

  • 直接进入shell

依赖项

bicti是用Python编写的;它支持从2.6版本开始的所有版本。它还依赖于runithttp://smarden.org/runit/)进行守护进程管理。

设置

在您的Dockerfile中添加

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"

这将

  1. 检索bicti及其依赖项

  2. 加载您的配置文件(预期位于/etc/bicti.ini

  3. 设置/etc/runit中的所有守护进程启动脚本

  4. 将bicti声明为您的入口点。

核心概念

除了几个命令行标志外,bicti的大部分工作都是在设置runit的配置。

启动时,bicti将

  1. 加载其配置文件(/etc/bicti.ini

  2. 设置runit以启动声明的服务

  3. 将控制权交给runit,它处理守护进程自动重启、孤儿进程回收等。

用法

$ 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 = /sbin/my-image-setup
; Run once all services have been stopped
teardown = /sbin/my-image-cleanup

; One section per service
[cron]
; Actual command to run
command = /usr/bin/cron
; Require another service to be started first
after = syslog

[uwsgi]
command = /usr/bin/uwsgi
; Command to run before starting the service
setup_command = mkdir /var/log/uwsgi
; Special uid/gid
uid = www-data
gid = www-data

项目详情


下载文件

下载适用于您的平台的文件。如果您不确定选择哪个,请了解有关安装包的更多信息。

源分发

bicti-0.1.1.tar.gz (5.4 kB 查看哈希)

上传时间