bicti,docker容器内的高效启动脚本
bicti的Python项目详细描述
Docker容器的简单启动工具。
bicti是作为一个容器的入口, 并为可能需要多个服务的系统提供一些帮助程序 (例如,fastcgi和nginx以及cron和logrotate)。
其功能包括:
- 支持命令的声明性列表
- 启动所有演示或仅启动少数演示
- 改为放入壳中
相关性
bicti是用python编写的;它支持2.6以后的所有版本。 它还依赖于runit(http://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"
这将:
- 检索bicti及其依赖项
- 加载bicti.ini配置文件(应位于/etc/bicti.ini)
- 在/etc/runit 中设置所有后台程序启动脚本
- 声明bicti为您的入口点。
核心概念
除了一些命令行标志之外,bicti的大部分工作是设置配置 对于runit。
启动后,BICTI将:
- 加载其配置文件(/etc/bicti.ini)
- 设置runit以启动声明的服务
- 将控制传输到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 startedsetup=/sbin/my-image-setup; Run once all services have been stoppedteardown=/sbin/my-image-cleanup; One section per service[cron]; Actual command to runcommand=/usr/bin/cron; Require another service to be started firstafter=syslog[uwsgi]command=/usr/bin/uwsgi; Command to run before starting the servicesetup_command=mkdir /var/log/uwsgi; Special uid/giduid=www-datagid=www-data