Home > Software engineering >  How to install bash on a bitnami/prometheus image?
How to install bash on a bitnami/prometheus image?

Time:01-06

I'm trying to use the bitnami/prometheus container which, according to its documentation, is based on the minideb container image which does not have a shell. I would like to install a Bash shell for debugging purposes. I've noticed that this works on the bitnami/minideb image directly, i.e. the following Dockerfile,

FROM bitnami/minideb:latest
RUN install_packages bash

builds successfully:

> docker build -t prometheus .
[ ] Building 7.8s (6/6) FINISHED                                                                                                                                           
 => [internal] load build definition from Dockerfile                                                                                                                  0.0s
 => => transferring dockerfile: 96B                                                                                                                                   0.0s
 => [internal] load .dockerignore                                                                                                                                     0.0s
 => => transferring context: 2B                                                                                                                                       0.0s
 => [internal] load metadata for docker.io/bitnami/minideb:latest                                                                                                     2.8s
 => [1/2] FROM docker.io/bitnami/minideb:latest@sha256:643da48745542c1b8e51a9b79beabc958731c4b539e1fa2261475c69d8e2058e                                               0.0s
 => => resolve docker.io/bitnami/minideb:latest@sha256:643da48745542c1b8e51a9b79beabc958731c4b539e1fa2261475c69d8e2058e                                               0.0s
 => => sha256:643da48745542c1b8e51a9b79beabc958731c4b539e1fa2261475c69d8e2058e 741B / 741B                                                                            0.0s
 => => sha256:aeb2b928697a7e94189f3faf4cf18f3b505a907ab7df55924e763147524c96f6 528B / 528B                                                                            0.0s
 => => sha256:591c594084e5b5c2636b2d41b8626ae3f6624b2b5db93fb6a881a08cc93f14f9 910B / 910B                                                                            0.0s
 => [2/2] RUN install_packages bash                                                                                                                                   4.8s
 => exporting to image                                                                                                                                                0.0s
 => => exporting layers                                                                                                                                               0.0s
 => => writing image sha256:9e1a4250e9ff3de115d9f286c904b5aa4da5ba5f0234336a5c22c2d31ce203be                                                                          0.0s
 => => naming to docker.io/library/prometheus                                                                                                                         0.0s

However, if I use bitnami/prometheus instead of bitnami/minideb,

FROM bitnami/prometheus:latest
RUN install_packages bash

an attempt to build it leads to an error due to a missing directory /var/lib/apt/lists/partial:

> docker build -t prometheus .
[ ] Building 0.4s (5/5) FINISHED                                                                                                                                           
 => [internal] load build definition from Dockerfile                                                                                                                  0.0s
 => => transferring dockerfile: 99B                                                                                                                                   0.0s
 => [internal] load .dockerignore                                                                                                                                     0.0s
 => => transferring context: 2B                                                                                                                                       0.0s
 => [internal] load metadata for docker.io/bitnami/prometheus:latest                                                                                                  0.0s
 => CACHED [1/2] FROM docker.io/bitnami/prometheus:latest                                                                                                             0.0s
 => ERROR [2/2] RUN install_packages bash                                                                                                                             0.3s
------
 > [2/2] RUN install_packages bash:
#5 0.230 E: List directory /var/lib/apt/lists/partial is missing. - Acquire (2: No such file or directory)
#5 0.230 apt failed, retrying
#5 0.242 E: List directory /var/lib/apt/lists/partial is missing. - Acquire (2: No such file or directory)
#5 0.243 apt failed, retrying
#5 0.255 E: List directory /var/lib/apt/lists/partial is missing. - Acquire (2: No such file or directory)
------
executor failed running [/bin/sh -c install_packages bash]: exit code: 100

Any idea how to install Bash on bitnami/prometheus?

CodePudding user response:

By default, image bitnami/prometheus already has bash. You can run image bitnami/prometheus with docker run -d bitnami/prometheus:latest and get CONTAINER_ID with docker ps then check with command

docker exec -it CONTAINER_ID /bin/bash

If you want to install other packages use following command in Dockerfile

FROM bitnami/prometheus:latest
RUN apt install package_name
  •  Tags:  
  • Related