goss docker-compose 集成使用

原理很简单,就是使用volume 进行数据共享, 并执行服务器状态校验

docker-compose 文件

version: "3"
services:
  goss:
    image: aelsabbahy/goss
    container_name: goss
    command: goss
    volumes:
    - code:/goss
  web:
    image: nginx
    environment:
    - GOSS_PATH=/goss
    - GOSS_FILES_PATH=/gossfile/
    ports:
    - 8080:80
    volumes:
    - code:/goss
    - ./gossfiles/:/gossfile/
volumes:
    code:

运行测试

默认已经挂载了一个配置文件,可以按照时间情况修改

  • 进入容器
实际参考docker-compose 文件目录,或者clone git 项目
docker exec -it goss-proejct_web_1 sh
  • 执行校验
/goss/goss -g /gossfile/goss.yaml validate
  • 效果

说明

实际上可以把goss 的http 进程进去,可以方便进行状态信息的搜集

参考资料

https://github.com/aelsabbahy/goss-docker
https://github.com/rongfengliang/goss-docker-compose

原文地址:https://www.cnblogs.com/rongfengliang/p/9693987.html