Python flask web run by Docker
*using ODBC:
- The server need to install ODBC driver
- Copy odbcinst.ini to container
COPY odbcinst.ini /etc/odbcinst.ini
- The docker need to install odbc before pip install pyodbc
RUN apt-get update && apt-get install -y --no-install-recommends \
unixodbc-dev \
unixodbc \
libpq-dev
- vim odbcinst.ini , check odbc driver path, then run image setting volumn path
docker run -v /opt/microsoft/:/opt/microsoft/ -p 5000:5000 ProjectName
-Dockerfile:
FROM python:3.7-rc
RUN apt-get update && apt-get install -y --no-install-recommends \
unixodbc-dev \
unixodbc \
libpq-dev
COPY odbcinst.ini /etc/odbcinst.ini
RUN mkdir /TargetPath
COPY ./Project /TargetPath
# set environment variables
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1
# set work directory
WORKDIR /TargetPath
# install dependencies
RUN pip install --upgrade pip
RUN pip install -r requirements.txt
CMD ["python", "main.py"]
留言
張貼留言