Docker Community Forums

Share and learn in the Docker community.

Install python in dockerfile

I want to install python in the dockerfile but when I test it with RUN python -V it says:

/bin/sh 1 python not found.

I have also tried building python from source, but still get this error. Can someone help? There is something wrong with the aliases I think.

FROM yummygooey/raspbian-buster
RUN apt-get update
RUN apt-get remove --purge -y python3.7

Install Python

RUN apt-get install -y python3.6
CMD alias python3=/usr/bin/python3.6
CMD alias python=/usr/bin/python3.6

RUN /bin/bash -c alias python=/usr/bin/python3.6
RUN /bin/bash -c echo ‘alias python=python3.6’ >> ~/.bashrc
RUN echo -e ‘#!/bin/bash\npython3=/usr/bin/python3.6’ > ~/.bashrc &&
chmod +x ~/.bashrc
RUN python3 -V