user11726874
user11726874

Reputation:

Docker Won't Install Python

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.

Upvotes: 0

Views: 668

Answers (1)

Arkadiusz Drabczyk
Arkadiusz Drabczyk

Reputation: 12383

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.

Upvotes: 2

Related Questions