Reputation: 340
So, im trying to learn docker and tried making a simple image to try it out. The docker build part goes well but when I docker run, I get a problem:
(base) daniellombardi@Daniels-MacBook-Pro MyApp-test % docker run bd
/bin/sh: 1: python: not found
The Dockerfile:
FROM ubuntu
RUN apt-get update && apt-get install -y python3 python3-pip
RUN pip3 install flask
RUN mkdir /MyApp-test
ADD folder /opt/MyApp-test
EXPOSE 5000
CMD python .main.py
and for anyone wondering, this is the code on main.py
from flask import Flask
app = Flask(__name__)
@app.route('/')
def index():
return 'IT WORKED! I AM RUNNING FROM A DOCKER CONTAINER!!!'
if __name__ == '__main__':
app.run(host="0.0.0.0", port=5000)
Upvotes: 5
Views: 16917
Reputation: 1377
Since you are only install python3
inside the docker image as shown here
RUN apt-get update && apt-get install -y python3 python3-pip
So you will need to run python3
instead of python
in this line: CMD python .main.py
And you have a typo in the script name. It should be main.py
instead of .main.py
. Or it should be ./main.py
So change it to CMD python3 ./main.py
And if you still have error, you probably need to add this line in the Dockerfile
above line of EXPOSE 5000
:
WORKDIR /opt/MyApp-test
Upvotes: 6