docker - 当我尝试从容器运行时,我的自定义节拍找不到 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}'
解决方案
在CMD
在线Dockerfile
,我添加了命令 cd /mybeatfolder 并且它起作用了。Libbeat 默认在当前文件夹中搜索配置文件,因此在执行我的节拍之前移动到正确的目录解决了它。
推荐阅读
- c# - 如何让 StreamReader 将 0xDF 读取为“es zet”?
- node.js - 关系的 JSON 最佳实践
- ruby-on-rails - 如何将 css 样式表包含到 wicked pdf 中?
- json - 有没有办法将json格式转换为Prometheus格式
- java - 如何连接 Web Api Spotify(Java 中)?
- c++ - 如何使用 RSM(反射阴影映射)获得平滑的结果?
- protocol-buffers - 清除 ProtobufMessage Java 中的字段
- python - 对列使用 apply split()
- javascript - 你如何为 getInitialProps 编写 Jest 测试?
- javascript - 带有 TinyMCE 编辑器的 IBM/HCL Connections 5 CR6 中的插件