首页 > 解决方案 > 当我尝试从容器运行时,我的自定义节拍找不到 custombeat.yml

问题描述

所以,我用法师 GenerateCustomBeat 构建了一个节拍,它运行良好,除了,现在我正在尝试对它进行容器化。当我运行我构建的图像时,它抱怨没有找到 customBeat.yml。RUN ls .我通过在 Dockerfile 末尾添加一行来确保该文件存在于文件夹中。

节拍名称是 coletorbeat,因此该名称在 Dockerfile 中出现多次。

执行时sudo docker run coletorbeat出现以下错误消息: Exiting: error loading config file: stat coletorbeat.yml: no such file or directory 如果有办法在我执行节拍时指定 coletorbeat.yml 文件位置,CMD我想我会解决它,但我还没有找到解决方法。

我将在下面发布 Dockerfile。我知道 beater 文件夹中的代码可以正常工作。我猜我在容器化方面犯了一些错误。

Dockerfile:

FROM ubuntu
MAINTAINER myNameHere

ARG ${ip:-"333.333.333.333"}
ARG ${porta:-"4343"}
ARG ${dataInicio:-"2020-01-07"}
ARG ${dataFim:-"2020-01-07"}
ARG ${tipoEquipamento:-"type"}
ARG ${versao:-"2"}
ARG ${nivel:-"0"}
ARG ${instituicao:-"RJ"}

ADD . .
RUN mkdir /etc/coletorbeat
COPY /coletorbeat/coletorbeat.yml /etc/coletorbeat/coletorbeat.yml

RUN apt-get update && \
    apt-get install -y wget git
RUN wget https://storage.googleapis.com/golang/go1.14.4.linux-amd64.tar.gz
RUN tar -zxvf go1.14.*.linux-amd64.tar.gz -C /usr/local
RUN mkdir /go

ENV GOROOT /usr/local/go
ENV GOPATH $HOME/go
ENV PATH $PATH:$GOROOT/bin:$GOPATH/bin

RUN echo $PATH
RUN go get -u -d github.com/magefile/mage
RUN cd $GOPATH/src/github.com/magefile/mage && \
    go run bootstrap.go
RUN apt-get install -y python3-venv
RUN apt-get install -y build-essential
RUN cd /coletorbeat && chmod go-w coletorbeat.yml && ./coletorbeat setup
RUN cd /coletorbeat && ./coletorbeat test config -c /coletorbeat/coletorbeat.yml && ls .

CMD ./coletorbeat/coletorbeat -E 'coletorbeat.ip=${ip}'

标签: dockerelasticsearch

解决方案


CMD在线Dockerfile,我添加了命令 cd /mybeatfolder 并且它起作用了。Libbeat 默认在当前文件夹中搜索配置文件,因此在执行我的节拍之前移动到正确的目录解决了它。


推荐阅读