[英]Failed to Fetch error when trying to build docker image (while RUN apt-get update)
[英]error building docker image 'executor failed running [/bin/sh -c apt-get -y update]'
我正在嘗試構建一個 docker 鏡像,但它拋出了一個錯誤,我似乎無法弄清楚原因。
它停留在RUN apt-get -y update
並顯示以下錯誤消息:
4.436 E: Release file for http://security.debian.org/debian-security/dists/buster/updates/InRelease is not valid yet (invalid for another 2d 16h 26min 22s). Updates for this repository will not be applied.
4.436 E: Release file for http://deb.debian.org/debian/dists/buster-updates/InRelease is not valid yet (invalid for another 3d 10h 28min 24s). Updates for this repository will not be applied.
executor failed running [/bin/sh -c apt-get -y update]: exit code: 100
這是我的泊塢窗文件:
FROM python:3.7
# Adding trusting keys to apt for repositories
RUN wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add -
# Adding Google Chrome to the repositories
RUN sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google-chrome.list'
# Updating apt to see and install Google Chrome
RUN apt-get -y update
# Magic happens
RUN apt-get install -y google-chrome-stable
# Installing Unzip
RUN apt-get install -yqq unzip
# Download the Chrome Driver
RUN CHROMEDRIVER_RELEASE=$(curl http://chromedriver.storage.googleapis.com/LATEST_RELEASE) && \
echo "Chromedriver latest version: $CHROMEDRIVER_RELEASE" && \
wget --quiet "http://chromedriver.storage.googleapis.com/$CHROMEDRIVER_RELEASE/chromedriver_linux64.zip" && \
unzip chromedriver_linux64.zip && \
rm -rf chromedriver_linux64.zip && \
mv chromedriver /usr/local/bin/chromedriver && \
chmod +x /usr/local/bin/chromedriver && \
chromedriver --version
# Set display port as an environment variable
ENV DISPLAY=:99
WORKDIR /
COPY requirements.txt ./
RUN pip install --upgrade pip && pip install -r requirements.txt
COPY . .
RUN pip install -e .
這里發生了什么?
更正您的系統時鍾。 (在評論中我還建議檢查時鍾和您的時區之間的不匹配)
就我而言,docker 仍在使用緩存的RUN apt update && apt upgrade
命令,因此沒有更新 package 源。
解決方案是使用--no-cache
標志構建一次 docker 映像:
docker build --no-cache .
如果您使用的是 docker 桌面,請檢查設置/首選項中是否設置了足夠的資源。 例如。 memory 和磁盤要求
這也特定於操作系統。
我在 Windows 10 上運行 MariaDB 時遇到了同樣的問題。
檢查 Docker 設置:
{
"registry-mirrors": [],
"insecure-registries": [],
"debug": false,
"experimental": false,
"features": {
"buildkit": true
},
"builder": {
"gc": {
"enabled": true,
"defaultKeepStorage": "20GB"
}
}
}
刪除下面的塊,它應該可以工作:
"features": {
"buildkit": true
},
當我輸入錯誤的 package 的名稱時,我收到此ERROR: executor failed running [...]: exit code: 100
錯誤消息。
這是在我的 Dockerfile 中:
RUN sudo apt-get update; \
sudo apt-get -y upgrade; \
sudo apt-get install -y gnupg2 wget lsb_release
而不是這個:
RUN sudo apt-get update; \
sudo apt-get -y upgrade; \
sudo apt-get install -y gnupg2 wget lsb-release
(請參閱下划線和破折號之間的區別。)
修復 package 名稱解決了該問題。
我有這個錯誤,我認為這是因為我安裝了buildx
但插件的版本與我的 docker 安裝不匹配。 卸載 buildx 為我解決了這個問題:
docker buildx uninstall
對我來說,將它添加到 Dockerfile 就完成了工作:
RUN apk add --update linux-headers;
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.