Sh: ./élastique-agent: introuvable lors de l'exécution de l'élastique de l'agent sur Alpine Linux

0

La question

Je suis en train de configurer l'Élastique de l'Agent sur un panneau contenant un autre service. Le conteneur est basé sur Alpine Linux, mais je ne peux pas courir à l'élastique-agent de commande de l'agent après le téléchargement et l'extraction de l'agent : il se plaint d'un "pas trouvé de fichier", alors que le fichier existe réellement!

Voici une minime reproductible exemple

docker run --rm -it alpine sh
# cd /opt
# wget https://artifacts.elastic.co/downloads/beats/elastic-agent/elastic-agent-7.14.2-linux-x86_64.tar.gz
# tar xvf elastic-agent-7.14.2-linux-x86_64.tar.gz
# cd elastic-agent-7.14.2-linux-x86_64/
# ./elastic-agent
sh: ./elastic-agent: not found
# ls -la
total 8452
drwxr-xr-x    3 root     root          4096 Nov 18 17:38 .
drwxr-xr-x    1 root     root          4096 Nov 18 17:38 ..
-rw-r--r--    1 root     root            41 Sep 15 17:00 .build_hash.txt
-rw-r--r--    1 root     root            41 Sep 15 17:00 .elastic-agent.active.commit
-rw-r--r--    1 root     root         13675 Sep 15 16:54 LICENSE.txt
-rw-r--r--    1 root     root       8586842 Sep 15 16:54 NOTICE.txt
-rw-r--r--    1 root     root           866 Sep 15 17:00 README.md
drwxr-xr-x    3 root     root          4096 Nov 18 17:38 data
lrwxrwxrwx    1 root     root            39 Nov 18 17:38 elastic-agent -> data/elastic-agent-574c21/elastic-agent
-rw-r--r--    1 root     root          9020 Sep 15 16:55 elastic-agent.reference.yml
-rw-------    1 root     root          9017 Sep 15 16:55 elastic-agent.yml
# ./data/elastic-agent-574c21/elastic-agent
sh: ./data/elastic-agent-574c21/elastic-agent: not found

Je suis en cours d'exécution sur x86_64 hôte comme on peut le voir avec la version du noyau ou le package de repos:

# uname -a
Linux 59ae07b0dca8 5.10.47-linuxkit #1 SMP Sat Jul 3 21:51:47 UTC 2021 x86_64 Linux
# apk update
fetch https://dl-cdn.alpinelinux.org/alpine/v3.14/main/x86_64/APKINDEX.tar.gz
fetch https://dl-cdn.alpinelinux.org/alpine/v3.14/community/x86_64/APKINDEX.tar.gz
v3.14.3-14-g9234faeb0d [https://dl-cdn.alpinelinux.org/alpine/v3.14/main]
v3.14.3-12-g13e0706e2c [https://dl-cdn.alpinelinux.org/alpine/v3.14/community]
OK: 14942 distinct packages available

Au il semble que le binaire pouvez faire un lien vers les bibliothèques correctement:

# ldd  ./data/elastic-agent-574c21/elastic-agent
    /lib64/ld-linux-x86-64.so.2 (0x7f1868c2f000)
    libpthread.so.0 => /lib64/ld-linux-x86-64.so.2 (0x7f1868c2f000)
    libdl.so.2 => /lib64/ld-linux-x86-64.so.2 (0x7f1868c2f000)
    libc.so.6 => /lib64/ld-linux-x86-64.so.2 (0x7f1868c2f000)

Il également possède les autorisations pour exécuter

# ls -la /usr/local/bin/elastic-agent-7.14.2-linux-x86_64/data/elastic-agent-574c21/
total 57244
drwxr-xr-x    3 root     root          4096 Nov 18 17:38 .
drwxr-xr-x    3 root     root          4096 Nov 18 17:38 ..
drwxr-xr-x    2 root     root          4096 Nov 18 17:38 downloads
-rwxr-xr-x    1 root     root      58603536 Sep 15 17:00 elastic-agent

strace ne semble pas aider ni

# strace -f ./elastic-agent
execve("./elastic-agent", ["./elastic-agent"], 0x7fff9e17bee8 /* 7 vars */) = -1 ENOENT (No such file or directory)
strace: exec: No such file or directory
+++ exited with 1 +++

Ai-je raté quelque chose? Pourrait Alpin empêcher un binaire de départ sous certaines conditions?

Merci pour votre aide!

alpine docker elastic-stack
2021-11-18 17:55:09
1

La meilleure réponse

2

Le problème semble être que la version compilée de elastic-agent que vous avez téléchargé exige de la libc. Alpine linux utilise muslc.

On peut installer glibc alpin à l'aide de https://stackoverflow.com/a/38433396/5666087. Et puis elastic-agent semble fonctionner.

FROM alpine
WORKDIR /opt
RUN wget -qO - https://artifacts.elastic.co/downloads/beats/elastic-agent/elastic-agent-7.14.2-linux-x86_64.tar.gz \
    | tar xz
# Add glibc
RUN wget -q -O /etc/apk/keys/sgerrand.rsa.pub https://alpine-pkgs.sgerrand.com/sgerrand.rsa.pub \
    && wget -q https://github.com/sgerrand/alpine-pkg-glibc/releases/download/2.28-r0/glibc-2.28-r0.apk \
    && apk add glibc-2.28-r0.apk \
    && rm glibc-2.28-r0.apk

Et exécuter l'image résultante (imaginons qu'il est nommé elastic):

docker run --rm -it elastic /opt/elastic-agent-7.14.2-linux-x86_64/elastic-agent
2021-11-18 18:48:38

Qui a résolu, merci! J'ai appris une autre chose sur les librairies de base de Linux aujourd'hui.
Thomas P.

Dans d'autres langues

Cette page est dans d'autres langues

Русский
..................................................................................................................
Italiano
..................................................................................................................
Polski
..................................................................................................................
Română
..................................................................................................................
한국어
..................................................................................................................
हिन्दी
..................................................................................................................
Türk
..................................................................................................................
Česk
..................................................................................................................
Português
..................................................................................................................
ไทย
..................................................................................................................
中文
..................................................................................................................
Español
..................................................................................................................
Slovenský
..................................................................................................................