尝试从容器中运行custombeat.yml时,我的自定义节拍找不到

时间:2020-08-03 22:31:52

标签: docker elasticsearch

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

beat名称为coletorbeat,因此该名称在Dockerfile中多次出现。

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

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

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}'

2 个答案:

答案 0 :(得分:0)

您正在将yml文件添加到/ etc目录中

COPY /coletorbeat/coletorbeat.yml /etc/coletorbeat/coletorbeat.yml

但是随后在/coletorbeat上运行命令而无需使用等。

答案 1 :(得分:0)

CMD的{​​{1}}行上,我添加了命令cd / mybeatfolder并成功运行。 Libbeat默认情况下会在当前文件夹中搜索配置文件,因此在执行Beat之前,请移至正确的目录。