2

I don't get it why python 3.5.2 is installed and not python 3.6. So I cannot execute my python file because I use f string literal syntax which is only available in python 3.6.

Maybe someone can help me?

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.6 --version && pip3 --version
RUN pip3 install gunicorn
ENV LANG C.UTF-8
ENV LC_ALL C.UTF-8
RUN mkdir /code
COPY . /code
WORKDIR /code

RUN pip3 install --no-cache-dir -r ./requirements.txt
ADD ./boot.sh /usr/local/bin/boot.sh
RUN chmod u+x /usr/local/bin/boot.sh

ENTRYPOINT /usr/local/bin/boot.sh
Tamara Koliada
  • 1,200
  • 2
  • 14
  • 31
Oiletz Matze
  • 125
  • 1
  • 3
  • 11
  • 1
    See [How do I install Python 3.6 using apt-get?](https://askubuntu.com/questions/865554/how-do-i-install-python-3-6-using-apt-get) as the envoy image is the cause of your misunderstanding. – dmulter Feb 15 '19 at 16:39

2 Answers2

2

This is an example of docker that uses Python 3.6

Basically it uses another repository. More information at this link.

But U can use an official docker image of python 3.6.

Do not use this:

FROM envoyproxy/envoy:latest

Use this instead:

FROM python:3.6-stretch

So the example that u passed would became:

FROM python:3.6-stretch

RUN python3.6 --version && pip3 --version
RUN pip3 install gunicorn
ENV LANG C.UTF-8
ENV LC_ALL C.UTF-8
RUN mkdir /code
COPY . /code
WORKDIR /code

RUN pip3 install --no-cache-dir -r ./requirements.txt
ADD ./boot.sh /usr/local/bin/boot.sh
RUN chmod u+x /usr/local/bin/boot.sh

ENTRYPOINT /usr/local/bin/boot.sh
Lucas Araújo
  • 429
  • 5
  • 17
  • And how do you suggest to install [envoyproxy/envoy](https://github.com/envoyproxy/envoy) after that? – Alex Yu Feb 15 '19 at 16:49
  • First of all I would try to use the other repository to install python 3.6, because the installation process seems to be more simple. – Lucas Araújo Feb 15 '19 at 16:59
  • But u can try open do dockerfile that created the envoyproxy docker image, and do the installation, but I searched a little bit and It is build when creating the imagem, and every time that u change the version of envoy u will need to rebuild, which probably take some time. – Lucas Araújo Feb 15 '19 at 17:00
  • You missed the point: it's much more easy to install python of any version than to build `envoyproxy`. Although it must not be very complicated too – Alex Yu Feb 15 '19 at 17:00
  • U can edit my post and add the option of use the python 3.6 docker image and install envoy, so another person with the same problem will have two options. – Lucas Araújo Feb 15 '19 at 17:24
  • I suppose: it's much more easy to add `apt-get install python-3.6` into `envoyproxy` image than to install envoyproxy into python image. – Alex Yu Feb 15 '19 at 17:43
  • thanks both of you for the help! would be great if @AlexYu can edit the post. – Oiletz Matze Feb 15 '19 at 17:44
2

Because if we look at envoy docker image we see:

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/*
...

Which have python-3.5.2 by default.

If you need python-3.6 - install it with apt, or build your own image.

Alex Yu
  • 3,412
  • 1
  • 25
  • 38