I have this in a Dockerfile:
RUN apt install -y python3-pip
how do I install a specific version of python though? Something like this:
RUN apt install -y python3-pip@python===3.6.7
I am looking for:
Python 3.6.7
If you want to install latest version just use RUN apt-get install python3 but if you want to install specific version of python you should do it manually for example were going to install python3.5.1:
sudo apt-get install libssl-dev openssl
wget https://www.python.org/ftp/python/3.5.1/Python-3.5.1.tgz
tar xzvf Python-3.5.1.tgz
cd Python-3.5.1
./configure
make
sudo make install
After installation completed set installed python as default one.
If you just want to install a specific version of Python over a simple Ubuntu, then why don't you directly use the official Python image corresponding to your needs ?
You can find all the supported images here : https://hub.docker.com/_/python
RUN /usr/bin/python3 -m pip install --upgrade pip==3.6.7
RUN /usr/bin/python3 -m pip install -r requirements.txt
This worked for me. Please note if you upgrade pip this way if only works with your python3 in /usr/bin/python3. So, you should install your requirements.txt as shown above.