docker - 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“测试”安装的解决方法或百胜。
我希望我已经尽可能清楚地说明了这个问题。
解决方案
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".
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.
推荐阅读
- oracle - 在 Oracle PL/SQL 中解码
- python - 使用列的最大值重新组合熊猫数据框的 Pythonic 方法
- c# - Datatable.addrow 引发 System.Data.EvaluateException
- python - 从多个数据帧中获取最大长度数据帧
- python - 加密文件时如何在没有字符串参数的情况下修复编码?
- sonarqube - 我们可以在 SonarQube 中扫描 IronPython 代码吗?
- sublimetext4 - Sublime Text 3 vs Sublime Text 4:缺少“连接到服务器功能”
- postgresql-13 - PostgreSQL 读取错误:读取:没有这样的文件或目录 sql
- google-chrome-extension - 挂钩到松弛通知
- python - CommitFailedError - Kafka 消费者参数