0

I am new to Docker. I used the following command to build an image but I get errors:

sudo docker build -t docker-custom-app .

Dockerfile:

FROM ubuntu:22.04

ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update && apt-get upgrade -y &&\
apt-get install -y curl &&\
apt-get install -y python3 &&\
apt-get install -y python3-pip &&\
pip install flask &&\
pip install flask-mysql

COPY . /opt/source-code

ENTRYPOINT FLASK_APP=/opt/source-code/app.py flask run

The error I get:

E: Unable to locate package curl The command '/bin/sh -c apt-get update && apt-get upgrade -y &&apt-get install -y curl &&apt-get install -y python3 &&apt-get install -y python3-pip &&pip install flask &&pip install flask-mysql' returned a non-zero code: 100

even if I use another RUN command, e.g.

RUN apt-get update && apt-get upgrade -y &&\
apt-get install -y software-properties-common &&\
pip install flask &&\
pip install flask-mysql

I get https://i.stack.imgur.com/0h3Cw.png

E: Unable to locate package software-properties-common The command '/bin/sh -c apt-get update && apt-get upgrade -y &&apt-get install -y software-properties-common &&pip install flask &&pip install flask-mysql' returned a non-zero code: 100

Or another RUN command example:

RUN apt-get update && apt-get upgrade -y &&\
apt-get install -y python3 &&\
apt-get install -y software-properties-common &&\
pip install flask &&\
pip install flask-mysql

I get an error:

E: Unable to locate package python3 The command '/bin/sh -c apt-get update && apt-get upgrade -y &&apt-get install -y python3 &&apt-get install -y software-properties-common &&pip install flask &&pip install flask-mysql' returned a non-zero code: 100

I always get an error something like Unable to locate package/returned a non-zero code:100

Any help is appreciated. Thanks.

aloha_erich
  • 133
  • 8
Thomas B
  • 13
  • 3
  • You seem to have included a link to a PNG file in place of the error message. Can you [edit] the question to include the actual error message? For layer-caching reasons you generally need to `RUN apt-get update && apt-get install` in a single command; do collapsing all of the `RUN` commands together improve things any? – David Maze Jul 13 '22 at 15:50
  • Hello David! Thanks for helping. I have edited Dockerfile, but I get the same error. – Thomas B Jul 13 '22 at 19:01
  • your error in the image does not match the dockerfile you wrote, why is that? – Aking Jul 13 '22 at 19:10
  • Hello Aking! This is because the RUN command I used before editing the Dockerfile is: RUN apt-get update && apt-get upgrade -y &&\ apt-get install -y software-properties-common &&\ pip install flask &&\ pip install flask-mysql It seems that even if I use another RUN command, e.g. RUN apt-get update && apt-get upgrade -y &&\ apt-get install -y python3 &&\ apt-get install -y software-properties-common &&\ pip install flask &&\ pip install flask-mysql I get an error like Unable to locate package/returned a non-zero code:100 In this case: E: Unable to locate package python3 – Thomas B Jul 13 '22 at 20:25
  • Thank you all for helping. I found the steps in https://stackoverflow.com/questions/24991136/docker-build-could-not-resolve-archive-ubuntu-com-apt-get-fails-to-install-a – Thomas B Jul 14 '22 at 10:03

1 Answers1

1

apt-get update caused the issue, it didn't work. I think your docker installation is somehow broken or you installed docker in a wrong way. Maybe you are on mac.

Slava Kuravsky
  • 2,702
  • 10
  • 16
  • Hello Kesha! Thanks for helping. I found the steps in https://stackoverflow.com/questions/24991136/docker-build-could-not-resolve-archive-ubuntu-com-apt-get-fails-to-install-a – Thomas B Jul 14 '22 at 10:03
  • Glad to help you. I will appreciate if you accept my answer, because it correctly points to the cause of your problem. Why update fails that's another question :) – Slava Kuravsky Jul 14 '22 at 10:47