Installing python3 python3-pip and awscli on elasticsearch_exporter container

9/9/2020

I am trying to install following packages on elasticsearch_exporter container. I tried yuminstall and apt-get and could not install using them. Can someone tell how to install packages on this container?

Linux elasticsearch-exporter-6dbd9cf659-7km8x 5.2.9-1.el7.elrepo.x86_64 #1 SMP Fri Aug 16 08:17:55 EDT 2019 x86_64 GNU/Linux

Error: apt-get install python3 sh: apt-get: not found

python3 python3-pip awscli

-- Kumar
amazon-web-services
containers
docker
kubernetes
linux

1 Answer

9/9/2020

If you are referring to justwatch/elasticsearch_exporter image, then it is based on busybox image (source). There is no package manager inside and adding one would be rather difficult.

An easy way to solve this is to just copy the exporter into regular Debian image, like this:

FROM justwatch/elasticsearch_exporter:1.1.0 as source

FROM debian:buster-slim
COPY --from=source /bin/elasticsearch_exporter /bin/elasticsearch_exporter

EXPOSE      9114
ENTRYPOINT  [ "/bin/elasticsearch_exporter" ]

And here is your exporter with apt inside.

-- anemyte
Source: StackOverflow