3

I try to update the python version in the envoy base image to python-3.6. But it doesn’t work.

Here is the base image I have to use (Envoy Proxy) which have python-3.5.2 by default 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/*
...

Here is my version with the deadsnake/ppa apt-get update

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

Thank you very much your help or some hints to find the solution by myself.

Oiletz Matze
  • 125
  • 1
  • 3
  • 11
  • Aha. So it looks like you did not solved [that problem](https://stackoverflow.com/questions/54713233/docker-installed-python-3-5-2-instead-of-python-3-6) completely. **"But it doesn’t work"** - please explain in more detail: a) python3.6 is not installed, b) python3.6 does not runs? – Alex Yu Feb 18 '19 at 12:18
  • hi Alex, thanks again for your help. if I run the container with "docker run -it sh" and look for the installed versions, python 3.6 is installed, but when I type "python3", python 3.5.2 is executed. Sorry, I a have not much knowledge. – Oiletz Matze Feb 18 '19 at 16:18

2 Answers2

1

python3 and pip3 exec points to system python3.5

I suggest to install pip on to python3.6 and allways use python3.6 and pip3.6 to refer to the new version.

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
pbacterio
  • 1,094
  • 6
  • 12
0

So I updated the Dockerfile with @pbacterio suggestion and it works now! Thank you very much

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
Oiletz Matze
  • 125
  • 1
  • 3
  • 11