首页 > 解决方案 > Gitlab Runner:在不同的机器上找不到 microdnf/yum 命令

问题描述

我有两台托管 gitlab-runner 的不同服务器机器。我使用一个作为开发版本,另一个作为生产版本。我在两台机器上都有相同的配置,所以 gitlab-runner 的最新版本和 Docker/docker-compose 的最新版本。

在我的 dockerfiles 中,我需要下载 net-tools 包才能使用 netstat 命令。builder docker 是 OpenJDK 14 的官方镜像,它基于 RHEL。所以,为了安装一个新包,我只能使用 dnf/microdnf 或 yum。


好的,到目前为止,一切都应该简单明了。但是......当机器尝试运行命令时:

RUN microdnf install net-tools

在分期机上:

/bin/sh: microdnf: 找不到命令

相反,在生产机器上:

乔布斯成功了。


好吧,那yum呢?让我们更改 Dockerfile 的 net-tools 安装

RUN yum install net-tools -y

管道启动,作业计划和...登台机器:

乔布斯成功了。

如您所见,在生产机器上:

/bin/sh: yum: 找不到命令


我觉得我有点被困住了,因为没有另一种安装包的方式(dnf 应该是另一种可能的方式,但它没有安装在两个 docker 映像上)并且我不想应用可以通过 microdnf“测试”安装的解决方法或百胜。

我希望我已经尽可能清楚地说明了这个问题。

标签: dockergitlab-ci-runneryumrheldnf

解决方案


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.


推荐阅读