4

I have two different server machine with gitlab-runner hosted. I use one as development version, the other one as production release. I have the same configuration on both machine, so the lastest release of gitlab-runner and the lastest release of Docker/docker-compose.

Into my dockerfiles I need to download net-tools package in order to use netstat command. The builder docker is an official image of OpenJDK 14 and it is RHEL based. So, in order to install a new package, i can use only dnf/microdnf or yum.


Ok, everything should work simple and clear as exposed so far. But... when the machines try to run the command:

RUN microdnf install net-tools

On staging machine:

/bin/sh: microdnf: command not found

Instead, on production machine:

Job succeeded.


Okay, so what about yum? Let's change Dockerfile's net-tools installation

RUN yum install net-tools -y

Pipeline started, job scheduled and... staging machine:

Job succeeded.

On production machine, as you can figure:

/bin/sh: yum: command not found


I feel i little bit trapped because there is not another way to install package (dnf should be another possible way but it is not install on both docker images) and I don't want apply a workaround that can "test" the installation via microdnf or yum.

I hope I've made the problem as clear as I can.

Bugpirasi
  • 371
  • 6
  • 22

1 Answers1

-1

This is not a proper solution, but at least it works. I mean, it's just a workaround that must be replaced as soon possible.

Anyway, in my docker-files, where I install microdnf/yum... I just do both, ignoring the errors. In Linux, you can "override" the exit status appending ';exit(0)' to you command.

RUN yum install net-tools -y; exit 0
RUN microdnf install net-tools -y; exit 0

On both machines what append is just execute the installations via yum and microdnf and, of course, one of them will carry out the operation successfully; instead, the other one will terminate with a "suffocated error".

The good one

The bad one

This workaround will allows you to overcome this problem in a really rough way, but at least... it works. The "suffocated error" will just ignored and the operation go through without crashes.

Bugpirasi
  • 371
  • 6
  • 22
  • Have you ever found a real solution? I'm facing the same problem with oraclelinux:8-slim. But I only have microdnf, no yum. – robotic_chaos Aug 11 '22 at 21:13
  • Actually, I didn't yet. I leaved the company where I did this.... stuff and they still have this configuration. What I suggest to you it's to try different package managers in order to find the right one.You should have in your pocket yum, dnf, microdnf and rpm. I know, it's something that breaks every best practice but... it works. – Bugpirasi Aug 14 '22 at 23:28