将Envoy Dockerfile基本映像更新为python 3.6+

问题描述 投票:2回答:2

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

这是我必须使用的基本图像(Envoy Proxy)默认情况下有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

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

python docker envoyproxy
2个回答
1
投票

python3和pip3 exec指向系统python3.5

我建议将pip安装到python3.6并始终使用python 3.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

0
投票

所以我用@pbacterio建议更新了Dockerfile,现在可以了!非常感谢你

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 curl https://bootstrap.pypa.io/get-pip.py | python3.6
RUN python3.6 --version && pip3.6 --version

COPY requirements.txt .
RUN pip3.6 install --no-cache-dir -r ./requirements.txt
RUN pip3.6 install gunicorn
ENV LANG C.UTF-8
ENV LC_ALL C.UTF-8
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
© www.soinside.com 2019 - 2024. All rights reserved.