Reputation: 26034
I'm starting with Docker. I have started with a Hello World script in Python 3. This is my Dockerfile:
FROM ubuntu:latest
RUN apt-get update
RUN apt-get install python3
COPY . hello.py
CMD python3 hello.py
In the same directory, I have this python script:
if __name__ == "__main__":
print("Hello World!");
I have built the image with this command:
docker build -t home/ubuntu-python-hello .
So far, so good. But when I try to run the script with this command:
docker run home/ubuntu-python-hello
I get this error:
/usr/bin/python3: can't find '__main__' module in 'hello.py'
What am I doing wrong? Any advice or suggestion is accepted, I'm just a newbie.
Thanks.
Upvotes: 2
Views: 3121
Reputation: 26034
Thanks to Gerrat, I solved it this way:
COPY hello.py hello.py
instead of
COPY . hello.py
Upvotes: 2
Reputation: 1
You need to install python this way and confirm it with the -y.
RUN apt-get update && apt-get install python3-dev -y
Upvotes: -1