How to install/enable or configure telnet to docker container for elk

This is the Dockerfile

FROM docker.elastic.co/beats/filebeat:7.8.0
RUN apt-get update && apt-get install -y telnet && rm -rf /var/lib/apt/lists/*
COPY ./filebeat.docker.yml /usr/share/filebeat/filebeat.yml

But unable to execute the second line… I tried with other filebeat:7.17.3 version as well but it gives the same error.
This is the error

[+] Building 0.7s (6/7)                                                                          docker:default
 => [internal] load build definition from Dockerfile                                                       0.1s
 => => transferring dockerfile: 222B                                                                       0.0s
 => [internal] load .dockerignore                                                                          0.1s
 => => transferring context: 2B                                                                            0.0s
 => [internal] load metadata for docker.elastic.co/beats/filebeat:7.8.0                                    0.0s
 => [1/3] FROM docker.elastic.co/beats/filebeat:7.8.0                                                      0.2s
 => [internal] load build context                                                                          0.1s
 => => transferring context: 464B                                                                          0.0s
 => ERROR [2/3] RUN apt-get update && apt-get install -y telnet && rm -rf /var/lib/apt/lists/*             0.4s
------
 > [2/3] RUN apt-get update && apt-get install -y telnet && rm -rf /var/lib/apt/lists/*:
0.375 /bin/sh: apt-get: command not found
------
Dockerfile:2
--------------------
   1 |     FROM docker.elastic.co/beats/filebeat:7.8.0
   2 | >>> RUN apt-get update && apt-get install -y telnet && rm -rf /var/lib/apt/lists/*
   3 |     COPY ./filebeat.docker.yml /usr/share/filebeat/filebeat.yml
   4 |
--------------------
ERROR: failed to solve: process "/bin/sh -c apt-get update && apt-get install -y telnet && rm -rf /var/lib/apt/lists/*" did not complete successfully: exit code: 127

Could somebody suggest me a way to resolve this? Tried with apk update as well it also doesn’t seem to work… I’m using ubuntu via wsl…

Don’t know what Linux distribution is used for the image, but that command does not work.

Did you try apt update && apt install telnet?

docker run --rm -it docker.elastic.co/beats/filebeat:7.8.0 cat /etc/os-release
NAME="CentOS Linux"
VERSION="7 (Core)"
ID="centos"
ID_LIKE="rhel fedora"
VERSION_ID="7"
PRETTY_NAME="CentOS Linux 7 (Core)"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:centos:centos:7"
HOME_URL="https://www.centos.org/"
BUG_REPORT_URL="https://bugs.centos.org/"

CENTOS_MANTISBT_PROJECT="CentOS-7"
CENTOS_MANTISBT_PROJECT_VERSION="7"
REDHAT_SUPPORT_PRODUCT="centos"
REDHAT_SUPPORT_PRODUCT_VERSION="7"

So that’s a centos and you need to use yum to install anything.

You can also find this information in the documentation

Quote:

Docker images for Filebeat are available from the Elastic Docker registry. The base image is centos:7.

1 Like