'Docker base image having telnet and ping

I have to debug network issues at a docker container. The container was built using "FROM registry.access.redhat.com/ubi7/ubi-minimal"

It has no "telnet" or "ping" like a normal shell has. That was by design in order to save space.

I tried to install them through yum within docker container shell – yum is not available They used something called “microdnf” which is like yum Tried “bash-4.2# microdnf install iputils” - No package matches 'iputils'. Similar result for telnet

Tried running it inside the dockerfile, where the image is created. It seem to be getting installed – but image creation explodes" “The command '/bin/sh -c yum install iputils' returned a non-zero code: 1”

I changed the image base from “FROM registry.access.redhat.com/ubi7/ubi-minimal” to “FROM registry.access.redhat.com/ubi7/ubi” This has yum available.

“yum install iputils” from container shell, and from docker file failed the same way.

Is there an image (preferably redhat) that will let me use "ping" and will process my Dockerfile correctly?

FROM registry.access.redhat.com/ubi7/ubi-minimal

RUN microdnf update -y && rm -rf /var/cache/yum
RUN microdnf clean all
RUN microdnf install shadow-utils

# Create a group and user
RUN groupadd -r myapp && useradd -r myapp -g myapp
RUN useradd -r aspisc  -g myapp

RUN mkdir -p /opt/smyapp/config
RUN mkdir -p /opt/smyapp/logs
RUN chown -R myapp:smyapp /opt/myapp

RUN mkdir -p /opt/myapp/bin && mkdir -p /opt/myapp/libs

RUN mkdir -p /opt/jre/

ENV JAVA_LIBS_CP /opt/myapp/libs
ENV LD_LIBRARY_PATH=/lib64
RUN echo JAVA_LIBS_CP=${JAVA_LIBS_CP}


EXPOSE 9500
EXPOSE 9501

ENTRYPOINT ["sh", "-c", "/opt/jre/bin/java $JAVA_OPTS -cp /opt/smyapp/bin/*:$JAVA_LIBS_CP/*...."] 


Solution 1:[1]

You are using the minimal base image (registry.access.redhat.com/ubi7/ubi-minimal). You can temporarily switch over to the non-minimal image (registry.access.redhat.com/ubi7/ubi) and install iputils there.

Solution 2:[2]

You can just add this one into ubi-minimal. As mentioned before, you can add only the iputils package.

USER root
RUN microdnf update && microdnf install sudo iputils hostname findutils less nano && microdnf clean all

Yo need to set ROOT user to be able add yum folders, but it's very important to set another user later on, remove the sudo command or remove the whole commands before you deploy the container to production. You can have very important flaws in your environment other wise.

You can also consider further knowledge of the container. As stated in Infinispan repo:

ubi-minimal image. Consequently, the image does not provide all of the tools that are commonly available in linux distributions. Below is a list of common tools/recipes that are useful for debugging.

Task Command
Text editor vi
Get the PID of the java process ps -fC java
Get socket/file information lsof
List all open files excluding network sockets lsof
List all TCP sockets ss -t -a
List all UDP sockets ss -u -a
Network configuration ip
Show unicast routes ip route
Show multicast routes ip maddress

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Christophe De Troyer
Solution 2