Dockerfile執行命令報錯The command 'binsh -c apt-get install -y git' returned a non-zero code 100解決

錯誤描述:
在Dockerfle裏面執行apt-get update時出現錯誤,我這裏時安裝mysql時出現如下報錯:
在這裏插入圖片描述
安裝數據庫的Dockerfile文件如下:

FROM ubuntu

MAINTAINER cwy

# 將sources.list複製到鏡像下的/etc/apt/下面,修改鏡像源地址
COPY sources.list /etc/apt/
# 拷貝SQL文件到home目錄下
COPY eshop.sql /home/
# 更新apt,因爲更換了sources.list,所以比較快,使用官方鏡像源在國外,速度比較慢
RUN apt-get clean && apt-get update
# 安裝MySQL
RUN apt-get -y install mysql-server
# mysqld.cnf文件中的字符串進行替換
RUN sed -Ei 's/127.0.0.1/0.0.0.0/' /etc/mysql/mysql.conf.d/mysqld.cnf
# 修改MySQL,ROOT用戶的密碼,創建數據庫eshop,導入eshop.sql數據文件到數據庫
RUN /etc/init.d/mysql start \
    && mysql -uroot -e "grant all privileges on *.* to 'root'@'%' identified by '123456';" \
    && mysql -uroot -e "grant all privileges on *.* to 'root'@'localhost' identified by '123456';" \
    && mysql -uroot -e "CREATE DATABASE IF NOT EXISTS eshop DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;" \
    && mysql -uroot -p123456 --default-character-set=utf8 eshop < /home/eshop.sql

EXPOSE 3306 

CMD ["/usr/bin/mysqld_safe"]

解決辦法:
RUN apt-get clean && apt-get update
替換爲RUN apt-get update --fix-missing && apt-get install -y fontconfig --fix-missing

其它錯誤參考如下網址:
1、Docker常見問題彙總及解決辦法(持續更新)
2、https://blog.csdn.net/m0_38015372/article/details/96750544

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章