How to install Python 3.14 in Rocky 9 docker image

I’m trying to install Python 3.14 with Rocky 9.3 Docker image as the base. I found these instructions to do it interactively, with no system dependencies ( eg dev packages ) specified , so I’ll have to guess at those.

cd /tmp/
wget https://www.python.org/ftp/python/3.14.0/Python-3.14.0.tgz
tar xzf Python-3.14.0.tgz
cd Python-3.14.0

sudo ./configure --prefix=/opt/python/3.14.0/ --enable-optimizations --with-lto --with-computed-gotos --with-system-ffi --with-openssl=/usr/local/ssl
sudo make -j "$(grep -c ^processor /proc/cpuinfo)"
sudo make altinstall
sudo rm /tmp/Python-3.14.0.tgz

I converted them to docker RUN commands for my dockerfile

WORKDIR /tmp/

RUN wget https://www.python.org/ftp/python/3.14.0/Python-3.14.0.tgz

RUN tar xzf Python-3.14.0.tgz

WORKDIR /tmp/Python-3.14.0

RUN ./configure --prefix=/opt/python/3.14.0/ --enable-optimizations --with-lto --with-computed-gotos --with-system-ffi --with-openssl=/usr/local/ssl

RUN make -j "$(grep -c ^processor /proc/cpuinfo)"

RUN make altinstall

I’m not sure if any of this works, so I’m curious if any other users have needed to install python newer than 3.12, and how they did i

Thanks

In the build part, not sure why you are building as root, and I’d be surprised if openssl resides in /usr/local.

In the make install part (altinstall), running as root, be very careful to know exactly which files it’s going to install, and to where.

I did get it to work, with PYTHON_VERSION=3.14.0

# Compile and install Python interpreter. Requires dev tools. Requires sqlite3 packages to support ansible-env

WORKDIR /tmp/

RUN wget https://www.python.org/ftp/python/${PYTHON_VERSION}/Python-${PYTHON_VERSION}.tgz

RUN tar xzf Python-${PYTHON_VERSION}.tgz

WORKDIR /tmp/Python-${PYTHON_VERSION}

RUN ./configure --enable-optimizations  --enable-loadable-sqlite-extensions && \ 
    make -j "$(grep -c ^processor /proc/cpuinfo)" && \
    make altinstall

This adds to the build time, but it gets the job done.

First off Rocky 9.3 is no longer supported. The current and only supported version is 9.6. By using the 9.3 images any packages you subsequently install on the system will come from 9.6. So then you’ll have a mix of 9.3 and 9.6 packages - not good.

But other than that, yes, if a package doesn’t exist in a repo for you to quickly download and install, then the only option is to compile what you need. And compilation takes time. If you weren’t too fussed about python 3.14, EPEL does have python 3.13 which you can use. There is the every offchance that EPEL will build and release 3.14 to their EPEL repo, at which point you would be able to save time.

There is another option to save time. Build python 3.14 using the configure and make commands on a Rocky 9 VM. Then tar up that directory into a python3.14.tar.gz, zip or whatever. You can then extract that archive into the container, and then just do a make install. If you need to repeat building the container, you already have the code ready to just extract and install. At least it saves you have to do the configure and make inside the Dockerfile when building the container, so saves a huge amount of time, especially for repeat builds.

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.