Skip to main content
 首页 » 编程设计

python之将 Envoy Dockerfile 基础镜像更新为 python 3.6+

2024年11月24日32hnrainll

我尝试将 envoy 基础镜像中的 python 版本更新为 python-3.6。但它不起作用。

这是我必须使用的基本图像(特使代理),默认情况下有 python-3.5.2 https://github.com/envoyproxy/envoy/blob/master/ci/Dockerfile-envoy-image

FROM ubuntu:16.04 
 
RUN apt-get update \ 
    && apt-get upgrade -y \ 
    && apt-get install -y ca-certificates \ 
    && apt-get autoremove -y \ 
    && apt-get clean \ 
    && rm -rf /tmp/* /var/tmp/* \ 
    && rm -rf /var/lib/apt/lists/* 
... 

这是我的 deadsnake/ppa apt-get 更新版本

FROM envoyproxy/envoy:latest 
 
RUN apt-get update && apt-get -q install -y \ 
    curl \ 
    software-properties-common \ 
    python-software-properties 
 
RUN add-apt-repository ppa:deadsnakes/ppa 
RUN apt-get update && apt-get -q install -y \ 
    python3.6 \ 
    python3-pip 
 
RUN python3 --version && pip3 --version 
 
RUN pip3 install gunicorn 
ENV LANG C.UTF-8 
ENV LC_ALL C.UTF-8 
COPY requirements.txt . 
RUN pip3 install --no-cache-dir -r ./requirements.txt 
RUN mkdir /code 
WORKDIR /code 
COPY . /code 
 
ADD ./boot.sh /usr/local/bin/boot.sh 
RUN chmod u+x /usr/local/bin/boot.sh 
 
ENTRYPOINT /usr/local/bin/boot.sh 

非常感谢您的帮助或一些提示,以便我自己找到解决方案。

请您参考如下方法:

python3和pip3 exec指向系统python3.5

我建议在python3.6上安装pip,并且总是使用python3.6和pip3.6来引用新版本。

RUN curl https://bootstrap.pypa.io/get-pip.py | python3.6 
RUN python3.6 --version && pip3.6 --version 
RUN pip3.6 install --no-cache-dir -r ./requirements.txt