栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Java

elastic-package 启动elastic报错 running Docker Compose build command failed: exit status 1

Java 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

elastic-package 启动elastic报错 running Docker Compose build command failed: exit status 1

背景

调试elastic integration,参考Test integration,使用elastic-package工具调试integration,启动elastic stack测试环境时(工具安装和概念参考上述链接官文):

elastic-package stack up 

报错:

Boot up the Elastic stack
Using profile /home/lsd/.elastic-package/profiles/default.
Remember to load stack environment variables using 'eval "$(elastic-package stack shellinit)"'.
Custom build packages directory found: /home/lsd/go/src/github.com/elastic/integrations/build/integrations
Packages from the following directories will be loaded into the package-registry:
- built-in packages (package-storage:snapshot Docker image)
- /home/lsd/go/src/github.com/elastic/integrations/build/integrations
Error: booting up the stack failed: building docker images failed: running command failed: running Docker Compose build command failed: exit status 1

大意是docker build镜像的时候出错,但具体什么错没给出来。

排查
    查看指令帮助看有没有途径打印详细信息
elastic-package stack up -h

Usage:
  elastic-package stack up [flags]

Flags:
  -d, --daemon             daemon mode
  -h, --help               help for up
  -s, --services strings   component services (comma-separated values: "elasticsearch,fleet-server,kibana,package-registry,elastic-agent")
      --version string     stack version (default "7.16.2")

Global Flags:
  -p, --profile string   select a profile to use for the stack configuration. Can also be set with ELASTIC_PACKAGE_PROFILE (default "default")
  -v, --verbose          verbose mode

可以看到 -v参数为verbose模式,一般就是用来打印详细执行过程的。

    加-v参数重新执行
elastic-package stack up -d -v
2022/01/18 10:29:17 DEBUG Enable verbose logging
2022/01/18 10:29:17 DEBUG Distribution built without a version tag, can't determine release chronology. Please consider using official releases at https://github.com/elastic/elastic-package/releases
Boot up the Elastic stack
Using profile /home/lsd/.elastic-package/profiles/default.
Remember to load stack environment variables using 'eval "$(elastic-package stack shellinit)"'.
Custom build packages directory found: /home/lsd/go/src/github.com/elastic/integrations/build/integrations
Packages from the following directories will be loaded into the package-registry:
- built-in packages (package-storage:snapshot Docker image)
- /home/lsd/go/src/github.com/elastic/integrations/build/integrations
2022/01/18 10:29:17 DEBUG running command: /usr/bin/docker-compose version --short
2022/01/18 10:29:18 DEBUG Determined Docker Compose version: , the tool will use Compose V1
2022/01/18 10:29:18 DEBUG running command: /usr/bin/docker-compose -f /home/lsd/.elastic-package/profiles/default/stack/snapshot.yml -p elastic-package-stack build
ERROR: The Compose file '/home/lsd/.elastic-package/profiles/default/stack/snapshot.yml' is invalid because:
services.elastic-agent.volumes contains an invalid type, it should be a string
Error: booting up the stack failed: building docker images failed: running command failed: running Docker Compose build command failed: exit status 1

这报错信息就详细多了:

ERROR: The Compose file '/home/lsd/.elastic-package/profiles/default/stack/snapshot.yml' is invalid because:
services.elastic-agent.volumes contains an invalid type, it should be a string

打开该文件找到对应位置

vi  /home/lsd/.elastic-package/profiles/default/stack/snapshot.yml
...
  elastic-agent:
    image: "${ELASTIC_AGENT_IMAGE_REF}"
    depends_on:
      fleet-server:
        condition: service_healthy
    healthcheck:
      test: "elastic-agent status"
      retries: 180
      interval: 1s
    hostname: docker-fleet-agent
    environment:
    - "FLEET_ENROLL=1"
    - "FLEET_INSECURE=1"
    - "FLEET_URL=http://fleet-server:8220"
    volumes:
    - type: bind
      source: ../../../tmp/service_logs/
      target: /tmp/service_logs/

这里的volumes格式的确跟别处不一样,其他地方都是形似如下格式的:

volumes:
      - "./kibana.config.${STACK_VERSION_VARIANT}.yml:/usr/share/kibana/config/kibana.yml"
      - "../../../stack/healthcheck.sh:/usr/share/kibana/healthcheck.sh"

这就是docker-compose执行的时候发现yaml文件校验不通过,可用docker-compose检测一下,会报同样的错:

docker-compose -f /home/lsd/.elastic-package/profiles/default/stack/snapshot.yml config

不过这不是我自己手写的,而且看格式应该也不是缩进错误,怀疑是docker-compose版本问题。

PS:** 虽然stackover flow上都说是compose.yaml文件(即这里的snapshot.yml)version不对,但那是elastic-package工具自动生成的,应当不大可能,并且试过手动修改多个version还是不行,所以docker-compose自身版本过低的可能性较高。**

参考https://docs.docker.com/compose/install/#install-compose
安装新版本docker-comopose

sudo curl -L "https://github.com/docker/compose/releases/download/v2.2.3/docker-compose-linux-x86_64" -o /usr/local/bin/docker-compose

 sudo chmod +x /usr/local/bin/docker-compose

重新执行 elastic-package stack up -d 不再报错。

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/709649.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号