skip to Main Content

I have been experimenting to create a docker image with python3.6 based on amazonlinux.
So far, I have not been very successful. I use

docker run -it amazonlinux

to start an interactive docker terminal. Inside the terminal, I run “yum install python36” and see the following error message. Note that I copied this step was from an old amazonlinux based Dockerfile. This Dockerfile used to work. So I suspend the error I see below is due to amazon updated their docker linux image

bash-4.2# yum install python36
Loaded plugins: ovl, priorities
amzn2-core       | 2.4 kB  00:00:00     
No package python36 available.
Error: Nothing to do

I have tried to add a python3.6 repo by following this post
https://janikarhunen.fi/how-to-install-python-3-6-1-on-centos-7 however, it still gives the same error when I run

yum install python36u

Is there any way to add python3.6 to amazonlinux base layer? Thanks in advance.

3

Answers


  1. You can check this Dockerfile based on amazon Linux and having python version is PYTHON_VERSION=3.6.4.

    Or you can work with your existing one like

    ARG PYTHON_VERSION=3.6.4
    ARG BOTO3_VERSION=1.6.3
    ARG BOTOCORE_VERSION=1.9.3
    ARG APPUSER=app
    
    RUN yum -y update &&
        yum install -y shadow-utils findutils gcc sqlite-devel zlib-devel 
                       bzip2-devel openssl-devel readline-devel libffi-devel && 
        groupadd ${APPUSER} && useradd ${APPUSER} -g ${APPUSER} && 
        cd /usr/local/src && 
        curl -O https://www.python.org/ftp/python/${PYTHON_VERSION}/Python-${PYTHON_VERSION}.tgz && 
        tar -xzf Python-${PYTHON_VERSION}.tgz && 
        cd Python-${PYTHON_VERSION} && 
        ./configure --enable-optimizations && make && make altinstall && 
        rm -rf /usr/local/src/Python-${PYTHON_VERSION}* && 
        yum remove -y shadow-utils audit-libs libcap-ng && yum -y autoremove && 
        yum clean all
    
    

    But better to clone the repo and make your own image form that.

    Login or Signup to reply.
  2. There is now a far easier answer to this question thanks to aws ‘extras’. Now this will work:

    amazon-linux-extras install python3
    
    Login or Signup to reply.
  3. I too had similiar issue for docker.

    yum install docker

    Loaded plugins: ovl, priorities
    amzn2-core | 3.7 kB 00:00:00
    No package docker available.
    Error: Nothing to do

    instead yum I used amazon-linux-extras, it worked

    amazon-linux-extras install docker

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search