I'm using this dockerfile with flask :
FROM python:3.8-slim-buster
WORKDIR /python-docker
COPY requirements.txt requirements.txt
RUN pip3 install -r requirements.txt
COPY . .
CMD [ "python3", "-m" , "flask", "run", "--host=0.0.0.0"]
It works fine, in my directory I have requirements.txt and a very simple app.py file :
from flask import Flask
app = Flask(__name__)
@app.route('/')
def hello_geek():
return '<h1>Hello from Flask & Docker</h2>'
if __name__ == "__main__":
app.run(debug=True)
I'd like to use it as a distroless image, so I build on this dockerfile :
FROM python:3.8-slim-buster as build-env
ADD / /app
WORKDIR /app
RUN pip3 install --upgrade pip
RUN pip install -r ./requirements.txt
FROM gcr.io/distroless/python3-debian10
COPY --from=build-env /app /app
COPY --from=build-env /usr/local/lib/python3.8/site-packages /usr/local/lib/python3.8/site-packages
WORKDIR /app
ENV PYTHONPATH=/usr/local/lib/python3.8/site-packages
CMD [ "python3", "-m" , "flask", "run", "--host=0.0.0.0"]
No error at build time, but when I run : sudo docker run python-dockerdistro
I get that error : /usr/bin/python3.7: can't open file 'python3': [Errno 2] No such file or directory
Do you have an idea of how resolve that error ? Thank you very much in advance