Why is my code still being executed with python3.5?

  docker, linux, python, python-3.x

I have a standard docker image for ubuntu 16.04 which I have to use for me project. This image contains python3.5 which is not supported anymore.

So, in my Dockerfile I remove python3.5 (user ROOT):

RUN update-alternatives --remove python /usr/bin/python3.5

Then I install python3.6 which works quite OK:

RUN apt-get update && apt-get install -y apt-transport-https && apt-get install build-essential -y

RUN apt-get install libssl-dev openssl -y &&
    wget https://www.python.org/ftp/python/3.6.7/Python-3.6.7.tgz &&
    tar xzvf Python-3.6.7.tgz &&
    cd Python-3.6.7 &&
    ./configure &&
    make &&
    make install

Furthermore, I install odbc-driver and a couple of other packages like: pytz and pyyaml:

RUN python3 -m pip install --upgrade pip &&
python3 -m pip install requests urllib3&&
python3 -m pip install pytz &&
python3 -m pip install pyyaml &&
apt install python3-pyodbc

Finally, I switch to a default user 1001 and then, using template of a colleague, enter this:

ENV ORDS=http://10.100.87.15:8080/ords/blabla
ENV PYTHONUNBUFFERED=TRUE
ENV PYTHONDONTWRITEBYTECODE=TRUE
ENV PATH="/opt:/opt/se:/opt/se/script:${PATH}"
ENV PYTHONPATH="${PYTHONPATH}:/usr/local/lib/python3.6/site-packages" 

Then I want to make sure I am using python3.6:

RUN alias python3='/usr/bin/python3.6'

And voila! My code is being executed with python3.5. Did I have to use RUN update-alternatives in the end of the dockerfile? Dis I have to put alias, maybe, straight after the installation of python3.6?

Source: Python-3x Questions

LEAVE A COMMENT