The command /bin/sh -c apt-get install -y git a non-zero code:100【解决方法】

今天爱分享给大家带来The command /bin/sh -c apt-get install -y git a non-zero code:100【解决方法】,希望能够帮助到大家。
Dockerfile文件中编辑如下内容:


# An example Dockerfile for installing Git on Ubuntu
From ubuntu
MAINTAINER "urmsone"
RUN apt-get install -y git
ENTRYPOINT ["git"]

执行 docker build -t test .命令后报错,The command ‘/bin/sh -c apt-get install -y git’ returned a non-zero code: 100
原因 使用ubuntu原始的源在apt-get install下载新包时,可能因为网络问题导致出现此报错。

解决:
更换源

1)sed -i ‘s#http://archive.ubuntu.com/#http://mirrors.tuna.tsinghua.edu.cn/#’ /etc/apt/sources.list;

2)apt-get update

3)添加–fix-missing

修正后的Dockerfile文件如下:


# An example Dockerfile for installing Git on Ubuntu
From ubuntu
MAINTAINER "urmsone"
RUN sed -i 's#http://archive.ubuntu.com/#http://mirrors.tuna.tsinghua.edu.cn/#' /etc/apt/sources.list;
RUN apt-get update --fix-missing && apt-get install -y git --fix-missing
ENTRYPOINT ["git"]

更换源后需在install之前需要先update,即apt-get update && apt-get install -y xxx
添加 –fix-missing参数
使用Dockerfile以ubuntu为基础新镜像时,常出现以上问题,大多数为网络问题,制作失败时,需要多尝试几次

原文链接:https://blog.itblood.com/4848.html,转载请注明出处。
0
我和朋友陪妈妈去露营 (Camp With Mom Extend)官方中文版 [PC+安卓] [1.5G] [SLG/中文/动态]
我和朋友陪妈妈去露营 (Camp With Mom Extend)官方中文版 [PC+安卓] [1.5G] [SLG/中文/动态]
5分钟前 有人购买 去瞅瞅看

站点公告

显示验证码
没有账号?注册  忘记密码?