所以,我用mage GenerateCustomBeat构建了一个beat,它运行得很好,只是现在我正在尝试对它进行共容器化。当我运行我构建的图像时,它抱怨找不到customBeat.yml。我已经通过在Dockerfile的末尾添加一行RUN ls .
来确保该文件存在于文件夹中。
节拍名称是coletorbeat,因此该名称在Dockerfile中多次出现。
在执行sudo docker run coletorbeat
时,我收到以下错误消息:Exiting: error loading config file: stat coletorbeat.yml: no such file or directory
如果有一种方法可以在我执行beat时指定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}'
您正在将yml文件添加到/etc/dir 中
COPY /coletorbeat/coletorbeat.yml /etc/coletorbeat/coletorbeat.yml
但随后在不使用等的情况下在/coletorbeat
上运行命令
在Dockerfile
的CMD
行,我添加了命令cd/mybeatfolder,它就工作了。Libbeat默认在当前文件夹中搜索配置文件,因此在执行我的beat之前移动到正确的目录解决了这个问题