Search code examples
dockerpython-3.6redhat

redhat7 docker image: how to install python3


I need to install python3 inside an RH7 docker image. Unfortunately, I am new to RedHat, and it seems that installing that python version is rather complex. Can I have either some help or a working Docker file?


Solution

  • You can update your Dockerfile accordingly, to use a base image with the desired python version:

    enter image description here Example Red Hat Enterprise Linux Server release 7.9 (Maipo) image with python3 already installed:

    
    $ docker run -itu 0 registry.access.redhat.com/ubi7/python-36 /bin/bash
    Unable to find image 'registry.access.redhat.com/ubi7/python-36:latest' locally
    latest: Pulling from ubi7/python-36
    1323a241cc06: Pull complete                                                                                                                                                                                                                  2bd25ca12457: Pull complete                                                                                                                                                                                                                  5d011ac93e74: Pull complete                                                                                                                                                                                                                  fa92b53b7e2a: Pull complete                                                                                                                                                                                                                  06e86f96ac44: Pull complete                                                                                                                                                                                                                  Digest: sha256:e7658aeaaf6c5897b602ad5a69f8c48761b494d47f27a2251036f363c4a0450f
    Status: Downloaded newer image for registry.access.redhat.com/ubi7/python-36:latest
    (app-root)
    (app-root) python --version
    Python 3.6.9