Docker container for Flask with Python3.7 on debian:10

I am creating a docker image and container for my flask project on python3.7 and debian 10.


FROM debian:10

# File Author / Maintainer

RUN apt-get update && apt-get install -y apache2 
&& apt-get clean 
&& apt-get autoremove 
&& rm -rf /var/lib/apt/lists/*

# Copy over and install the requirements
COPY ./requirements.txt /var/www/home/requirements.txt
RUN pip3 install -r /var/www/home/requirements.txt

# Copy over the apache configuration file and enable the site
COPY ./configs/apache-flask.conf /etc/apache2/sites-available/apache-flask.conf
RUN a2ensite apache-flask
RUN a2enmod headers

# Copy the code
COPY ./service /var/www/home/

RUN a2dissite 000-default.conf
RUN a2ensite apache-flask.conf


WORKDIR /var/www/home

CMD  /usr/sbin/apache2ctl -D FOREGROUND

my WSGI Apache conf

  <VirtualHost *:80>

  # Python application integration
  WSGIDaemonProcess /apache-flask processes=4 threads=20 python-path=/var/www/home/:/usr/bin/python3:/usr/local/lib/python3.7/dist-packages:/usr/lib/python3.7/
  WSGIProcessGroup /apache-flask
  WSGIScriptAlias / /var/www/home/ws.wsgi

  <Directory "/var/www/home/">
      Header set Access-Control-Allow-Origin "*"
      WSGIProcessGroup /apache-flask
      WSGIApplicationGroup %{GLOBAL}
      Options +ExecCGI
      Order deny,allow
      Allow from all
  ErrorLog ${APACHE_LOG_DIR}/error.log
  LogLevel warn
  CustomLog ${APACHE_LOG_DIR}/access.log combined

I have manually set up my app on one virtual server on digital ocean and everything works. But now when I create the container from this image I receive this error:

  mod_wsgi (pid=12): Failed to exec Python script file '/var/www/home/ws.wsgi'.
 mod_wsgi (pid=12): Exception occurred processing WSGI script '/var/www/home/ws.wsgi'.
Traceback (most recent call last):
File "/var/www/home/ws.wsgi", line 5, in <module>
from ws import app as application
File "/var/www/home/", line 2, in <module>
from flask import Flask, jsonify, request
File "/usr/local/lib/python3.7/dist-packages/flask/", line 14, in <module>
from jinja2 import escape
 File "/usr/local/lib/python3.7/dist-packages/jinja2/", line 6, in <module>
from markupsafe import escape
 File "/usr/local/lib/python3.7/dist-packages/markupsafe/", line 13, in <module>
 import string
File "/usr/lib/python3.7/", line 78
class Template(metaclass=_TemplateMetaclass):
 SyntaxError: invalid syntax

Source: StackOverflow