1 Star 0 Fork 0

aogg / docker-events-script

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

docker-events-script

根据docker events事件执行指定脚本

hub.docker.com https://hub.docker.com/r/adockero/events-script

events-script

使用

启动容器

// 简单使用,自带根据network事件执行nginx名称的容器重启配置
docker run --restart=always -d --privileged \
  -v /var/run/docker.sock:/var/run/docker.sock \
  --name events-script \
  adockero/events-script 

测试

docker run -i --rm --network host nginx ls

查看执行日志

docker logs -f adockero/events-script

ini配置文件

docker-scripts/events-script.ini文件

如下默认nginx重读配置的配置

[nginxReload]
args='-f "type=network" -f "event=connect"'
command='sleep 2 && docker exec -i nginx nginx -t && docker exec -i nginx nginx -s reload'

自定义事件脚本

1、[test]头必须英文无空格
2、只有两个配置参数。执行配置脚本是
docker-scripts/fifo_event.sh

3、args是docker events的命令参数
4、command是事件触发时只需的脚本,可以使用docker命令,多个命令用&&
5、如果是一个容器重新创建,就需要sleep等待容器能联通后在重启nginx

MIT License Copyright (c) 2020 aogg Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

根据docker events事件执行指定脚本 展开 收起
Shell
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
Shell
1
https://gitee.com/ao-lol/docker-events-script.git
git@gitee.com:ao-lol/docker-events-script.git
ao-lol
docker-events-script
docker-events-script
master

搜索帮助