简体   繁体   中英

Docker installed python 3.5.2 instead of python 3.6

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

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM