CentOS下Docker构建报错/bin/sh: url: command not found怎么解决
核心问题
CentOS 官方软件源不存在名为 url 的软件包,你遇到报错的根本原因是 Dockerfile 中的下载命令书写错误,Linux 下常用的命令行下载工具为 curl 和 wget,没有默认提供名为 url 的下载命令。
修复方案
你可以任选以下任意一种方案修改 Dockerfile 即可解决报错:
方案1:使用 curl 作为下载工具
- 在 yum 安装列表中添加
curl依赖 - 将原命令中的
url -O替换为curl -O
修改后的完整 RUN 指令如下:
RUN yum install python3 curl -y\ && curl -O https://bootstrap.pypa.io/get-pip.py \ && python3 get-pip.py\ #no --user - install for the whole machine && pip install awscli --upgrade
方案2:使用 wget 作为下载工具
- 在 yum 安装列表中添加
wget依赖 - 将原命令中的
url -O替换为wget(wget 默认会保留远程文件原名,无需额外加-O参数,加也可正常运行)
修改后的完整 RUN 指令如下:
RUN yum install python3 wget -y\ && wget https://bootstrap.pypa.io/get-pip.py \ && python3 get-pip.py\ #no --user - install for the whole machine && pip install awscli --upgrade
内容的提问来源于stack exchange,提问作者sb813322
相关产品推荐
相关产品推荐

