[英]Install python 3.9 on an amazon/aws-cli docker image
如何在默認情況下帶有 python 2.7 的 amazon/aws-cli docker 圖像之上安裝 Python 3.9? 到目前為止,我所嘗試的是基於安裝教程的這些系列命令,用於在 Amazon Linux 2 上安裝 Python 3:
FROM amazon/aws-cli:latest
WORKDIR ./
COPY ./.aws ./root/.aws
COPY . .
RUN yum install gcc openssl-devel bzip2-devel libffi-devel -y
RUN yum install wget tar -y
RUN cd /opt
RUN wget https://www.python.org/ftp/python/3.9.6/Python-3.9.6.tgz
RUN tar xzf Python-3.9.6.tgz
RUN cd Python-3.9.6
RUN ./configure --enable-optimizations
RUN make altinstall
RUN rm -f /opt/Python-3.9.6.tgz
RUN ["python3", "-u", "app.py"]
但我收到此錯誤:
[+] Building 13.5s (14/19)
=> [internal] load build definition from Dockerfile 0.1s
=> => transferring dockerfile: 32B 0.0s
=> [internal] load .dockerignore 0.1s
=> => transferring context: 2B 0.0s
=> [internal] load metadata for docker.io/amazon/aws-cli:latest 12.2s
=> [auth] amazon/aws-cli:pull token for registry-1.docker.io 0.0s
=> [ 1/14] FROM docker.io/amazon/aws-cli:latest@sha256:fd66db7596251aada 0.0s
=> [internal] load build context 0.1s
=> => transferring context: 1.19kB 0.0s
=> CACHED [ 2/14] WORKDIR ./ 0.0s
=> CACHED [ 3/14] COPY ./.aws ./root/.aws 0.0s
=> CACHED [ 4/14] COPY . . 0.0s
=> CACHED [ 5/14] RUN yum install gcc openssl-devel bzip2-devel libffi-d 0.0s
=> CACHED [ 6/14] RUN yum install wget tar -y 0.0s
=> CACHED [ 7/14] RUN cd /opt 0.0s
=> CACHED [ 8/14] RUN wget https://www.python.org/ftp/python/3.9.6/Pytho 0.0s
=> ERROR [ 9/14] RUN tar xzf Python-3.9.6.tgz 1.0s
------
> [ 9/14] RUN tar xzf Python-3.9.6.tgz:
#14 0.959 tar (child): gzip: Cannot exec: No such file or directory
#14 0.959 tar (child): Error is not recoverable: exiting now
#14 0.961 tar: Child returned status 2
#14 0.961 tar: Error is not recoverable: exiting now
您還必須安裝gzip
和make
並使用WORKDIR
:
FROM amazon/aws-cli:latest
WORKDIR ./
COPY ./.aws ./root/.aws
COPY . .
RUN yum install gcc openssl-devel bzip2-devel libffi-devel gzip make -y
RUN yum install wget tar -y
WORKDIR /opt
RUN wget https://www.python.org/ftp/python/3.9.6/Python-3.9.6.tgz
RUN tar xzf Python-3.9.6.tgz
WORKDIR /opt/Python-3.9.6
RUN ./configure --enable-optimizations
RUN make altinstall
RUN rm -f /opt/Python-3.9.6.tgz
RUN ["python3", "-u", "app.py"]
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.