sh: ./filebeat: 在 Docker 容器中找不到

发布于 2025-01-10 02:34:18 字数 2097 浏览 1 评论 0原文

我尝试在带有 s6 覆盖的 docker 容器中运行 filebeat。 当 s6 执行或手动执行 filebeat 二进制文件时,我得到 sh: ./filebeat: not find
这是我的 Dockerfile:

FROM alpine:3.15

ENV AM_I_IN_A_DOCKER_CONTAINER Yes

COPY root/ /
ADD https://github.com/just-containers/s6-overlay/releases/download/v1.21.8.0/s6-overlay-amd64.tar.gz /tmp/
ADD https://artifacts.elastic.co/downloads/beats/filebeat/filebeat-8.0.0-linux-x86_64.tar.gz /tmp/
ADD requirements.txt /etc/services.d/01_instabot/requirements.txt
ADD src/ /etc/services.d/01_instabot/

RUN chmod +x /usr/local/bin/install.sh
RUN /usr/local/bin/install.sh

#ENTRYPOINT ["/init"]

这是我的 install.sh:

#!/bin/sh

echo "Unpacking s6 overlay"
gunzip -c /tmp/s6-overlay-amd64.tar.gz | tar -xf - -C /

echo "Creating user"
adduser -D -u 2000 -s /sbin/nologin -D -H botuser
adduser -D -u 2001 -s /sbin/nologin -D -H filebeatuser

echo "Set time"
ln -snf /usr/share/zoneinfo/"$TZ" /etc/localtime && echo "$TZ" > /etc/timezone
apk add --no-cache tzdata

echo "Install filebeat"
gunzip -c /tmp/filebeat-8.0.0-linux-x86_64.tar.gz | \
  tar -xf - -C /etc/services.d/00_filebeat/ --strip-components=1
mv /etc/services.d/00_filebeat/my_filebeat.yml /etc/services.d/00_filebeat/filebeat.yml

echo "Install app dependencies"
apk add --no-cache python3 py3-pip
pip3 install --no-cache-dir -r /etc/services.d/01_instabot/requirements.txt
mv /etc/services.d/01_instabot/settings_docker.py /etc/services.d/01_instabot/settings.py

echo "Cleanup"
rm -rf /tmp/*

如果我使用 docker run 命令查看 docker 容器内部,我会看到存在的二进制文件。

/etc/services.d/00_filebeat # ls
LICENSE.txt             README.md               filebeat                filebeat.yml            module                  run
NOTICE.txt              fields.yml              filebeat.reference.yml  kibana                  modules.d

但是当我使用 ./filebeat 执行它时,我收到未找到错误。

/etc/services.d/00_filebeat # ./filebeat
sh: ./filebeat: not found

这是为什么呢?我该如何解决它?是因为busybox还是什么原因吗?

Im trying to run filebeat in a docker container with the s6 overlay.
When s6 executes or when i manually execute the filebeat binary i get sh: ./filebeat: not found
This is my Dockerfile:

FROM alpine:3.15

ENV AM_I_IN_A_DOCKER_CONTAINER Yes

COPY root/ /
ADD https://github.com/just-containers/s6-overlay/releases/download/v1.21.8.0/s6-overlay-amd64.tar.gz /tmp/
ADD https://artifacts.elastic.co/downloads/beats/filebeat/filebeat-8.0.0-linux-x86_64.tar.gz /tmp/
ADD requirements.txt /etc/services.d/01_instabot/requirements.txt
ADD src/ /etc/services.d/01_instabot/

RUN chmod +x /usr/local/bin/install.sh
RUN /usr/local/bin/install.sh

#ENTRYPOINT ["/init"]

This is my install.sh:

#!/bin/sh

echo "Unpacking s6 overlay"
gunzip -c /tmp/s6-overlay-amd64.tar.gz | tar -xf - -C /

echo "Creating user"
adduser -D -u 2000 -s /sbin/nologin -D -H botuser
adduser -D -u 2001 -s /sbin/nologin -D -H filebeatuser

echo "Set time"
ln -snf /usr/share/zoneinfo/"$TZ" /etc/localtime && echo "$TZ" > /etc/timezone
apk add --no-cache tzdata

echo "Install filebeat"
gunzip -c /tmp/filebeat-8.0.0-linux-x86_64.tar.gz | \
  tar -xf - -C /etc/services.d/00_filebeat/ --strip-components=1
mv /etc/services.d/00_filebeat/my_filebeat.yml /etc/services.d/00_filebeat/filebeat.yml

echo "Install app dependencies"
apk add --no-cache python3 py3-pip
pip3 install --no-cache-dir -r /etc/services.d/01_instabot/requirements.txt
mv /etc/services.d/01_instabot/settings_docker.py /etc/services.d/01_instabot/settings.py

echo "Cleanup"
rm -rf /tmp/*

If i take a look inside the docker container with the docker run command i see the binary present.

/etc/services.d/00_filebeat # ls
LICENSE.txt             README.md               filebeat                filebeat.yml            module                  run
NOTICE.txt              fields.yml              filebeat.reference.yml  kibana                  modules.d

But when i execute it using ./filebeat i get the not found error.

/etc/services.d/00_filebeat # ./filebeat
sh: ./filebeat: not found

Why is this? And how do i fix it? Is it because of busybox or something?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

憧憬巴黎街头的黎明 2025-01-17 02:34:18

我的高山图像中缺少 libc6-compat。

libc6-compat was missing from my alpine image.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文