As per the requirements i have to install python3 on top of amazoncorreto image so that python codes can be ran on container.
I have written below dockerfile for this
FROM amazoncorretto
ARG PYTHON_VERSION=3.6.4
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
after image is created i tried to run a container from that image
docker run -it image-name /bin/bash
python3.6.4 -V
command not found
python --version
2.7
I am not able to figure out why python is not getting installed here.
Also its taking very long time to build image.Below are the messages
make[1]: Entering directory `/usr/local/src/Python-3.6.4'
: # FIXME: can't run for a cross build
./python -m test.regrtest --pgo || true
Run tests sequentially
0:00:00 load avg: 0.97 [ 1/406] test_grammar
0:00:00 load avg: 0.97 [ 2/406] test_opcodes
0:00:00 load avg: 0.97 [ 3/406] test_dict
0:00:01 load avg: 0.97 [ 4/40
You have to also install tar gzip gcc make
using yum
as amazoncorretto
does not come with these packages. They are required to compile python.
FROM amazoncorretto
ARG PYTHON_VERSION=3.6.4
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 tar gzip gcc make && \
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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.