0

I recently started learning docker and I was attempting to build a flask python image by following a tutorial video.

FROM ubuntu:latest


RUN apt-get update
RUN apt-get install python

CMD echo "Python Installed"

RUN pip install flask

COPY . /opt/source-code

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

this is the Dockerfile in my source code working directory, I run sudo docker build . -t nxte/custom-app on a digitalocean droplet with docker installed but it returns The command '/bin/sh -c apt-get install python' returned a non-zero code: 1.

Any suggestions? I have no idea what the problem is since I followed the tutorial to a T.

1
  • Are there any logs from the build? Commented Oct 13, 2020 at 17:43

1 Answer 1

3

You should use -y with apt-get:

RUN apt-get -y install python

Also notice that the above does not install pip and it's not possible to install it with apt-get -y install python-pip so either switch to Python 3 and then apt-get -y install python3 and apt-get -y install python3-pip or get pip from other sources.

Sign up to request clarification or add additional context in comments.

1 Comment

Also, it's better to run all apt-get commands in one RUN section of Dockerifle to use fewer docker layers(the final image will use less space) docs.docker.com/develop/develop-images/…