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

时间:2019-02-18 12:11:11

标签: python docker envoyproxy

我尝试将使节基本映像中的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

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

2 个答案:

答案 0 :(得分:1)

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

答案 1 :(得分: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