user6723321
user6723321

Reputation:

Python3 in DockerFile running ubuntu::latest

I am trying to upgrade from running my script in Python 2.7 to Python 3.5. It is a simple Flask admin script running inside a docker container.

DockerFile:

FROM ubuntu:latest

RUN apt-get update -y && apt-get install -y python-pip python3.5-dev build-essential libpq-dev

....

CMD ["/usr/bin/python", "app.py"]

This runs it in python 2.7. I tried updating to

CMD ["/usr/bin/python3", "parcelnotifer.py"]

but this results in an error

Cannot start service dev: oci runtime error: exec: "/usr/bin/python3": stat /usr/bin/python3: no such file or directory

If I docker exec into the container when it is running on 2.7 I can use the command python3 so Python3 is definitely installed I am just not sure how to force the script to run in Python3

Upvotes: 6

Views: 12228

Answers (1)

ForceBru
ForceBru

Reputation: 44830

You can first check where Python is getting installed with which python3 and then put that path into your CMD command.

Upvotes: 4

Related Questions