问题
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
回答1:
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.
回答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
来源:https://stackoverflow.com/questions/54713233/docker-installed-python-3-5-2-instead-of-python-3-6