简体   繁体   中英

Failed to Fetch error when trying to build docker image (while RUN apt-get update)

I'm trying to create a flask-docker project, but i also need some tools from linux. So i have a debian:latest base image for my dockerfile, in which i want to install python3 and dieharder(the package i need for my project). But every time i try to build the image with following command: docker build --no-cache --pull -t backend . I get 3 packages that fail to fetch:

E: Failed to fetch http://deb.debian.org/debian/pool/main/g/gcc-defaults/gcc_10.2.1-1_amd64.deb  Bad header line Bad header data [IP: 151.101.14.132 80]
E: Failed to fetch http://deb.debian.org/debian/pool/main/g/gcc-defaults/g%2b%2b_10.2.1-1_amd64.deb  Bad header line Bad header data [IP: 151.101.14.132 80]
E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?
The command '/bin/sh -c apt-get update --fix-missing -y && apt-get install -y python3-pip && apt-get install -y dieharder' returned a non-zero code: 100

I'm already running everything in one RUN command and also using --no-cache, but i still get these errors. Also i could'nt find anyone else with these specific errors. So i'm asking for Your help, because i don't know what else i can do.

My Dockerfile:

FROM debian:latest

RUN apt-get update --fix-missing -y && apt-get install -y python3-pip && apt-get install -y dieharder

COPY ./requirements.txt /app/requirements.txt

WORKDIR /app

RUN pip install -r requirements.txt

COPY . /app

ENTRYPOINT [ "python" ] 

CMD ["main.py"]

Could it be a problem that im doing all this on a VM? Is there any further information you need to help me? Please let me know, this is my first question ever, so sry if it's not that good :) PS i don't really need to use debian as a base image but i would prefer to. I also tried Ubuntu and got the same error, so i don't think that thats the problem.

Update: It seems like i solved this problem, although I'm not really sure why it works now.
I had to change my run command and install gcc and g++ independently from apt-get update. I don't know if this is an elegant solution, but it works for now.
If anyone has a smoother solution pls let me know :)
Anyway here is my final Dockerfile:

FROM debian:latest

RUN apt-get update -y && apt-get install gcc-10 -y && apt-get install g++-10 -y && apt-get install -y python3-pip && apt-get install -y dieharder

COPY ./requirements.txt /app/requirements.txt

WORKDIR /app

RUN pip install -r requirements.txt

COPY . /app

ENTRYPOINT [ "python3" ] 

CMD ["main.py"]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM