docker - 无法在我的容器中安装解压缩工具

标签 docker docker-compose centos dockerfile centos7

我尝试在我的 centos 容器中安装 unzip

我的 Dockerfile 如下所示:

FROM centos
...

RUN apt-get update -y && apt-get upgrade -y
RUN apt-get install -y unzip

当我构建图像时,出现错误:

Step 9/12 : RUN apt-get update -y && apt-get upgrade -y
 ---> Running in 65457527bac0
/bin/sh: apt-get: command not found

如何在我的容器中安装解压工具?

最佳答案

由于您使用的是 CentOs,默认包管理器不是 apt-get,而是 yum。

所以这样做你的 dockerfile 应该是这样的:

FROM centos
...

RUN yum update
RUN yum install unzip

作为更详细的解释,您可以记住这一点:

apt-get 是基于 debian 的 Linux 发行版(如 Ubuntu 和其他一些发行版)的默认包管理器。 yum 是基于 RPM 的发行版的默认包管理器(Redhat 包管理器)

关于docker - 无法在我的容器中安装解压缩工具,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64046257/

相关文章:

docker-compose + 如何设置 ramdisk 而不是卷

docker-compose - 如何使用 docker Composer 添加reavenDB的服务器许可证

elasticsearch - 无法将 Elasticsearch 传输服务绑定(bind)到外部接口(interface)

linux - 将 rsa key 部署到其他机器

ruby - Ruby Kafka未捕获的异常:未能找到组协调器

docker - Gitlab CI/Docker : Use custom image for job

c# - 由于 Null 异常,.net core docker 容器在生产中退出并出现错误代码 139

docker - 从 docker 容器名称中删除随机字符串

.net - 无法访问我的 .NET 容器

postgresql - Docker - 检查 postgres 是否准备就绪