docker build python with mysql odbc
- python 2.7
- 采用分级创建
- 包含了mysql 数据库连接库
Dockerfile
FROM python:2.7.18-stretch as base
RUN mkdir /svc COPY . /svc WORKDIR /svc RUN apt-get update && apt-get install -y unixodbc-dev RUN pip install wheel && pip wheel --wheel-dir=/svc/wheels -r requirements.txt
FROM python:2.7.18-slim-stretch
COPY --from=base /svc /svc WORKDIR /svc RUN apt-get update && apt-get install -y unixodbc-dev && apt-get install -y libmariadbclient-dev RUN pip install --no-index --find-links=/svc/wheels -r requirements.txt
requirements.txt、
MySQL-python pyodbc requests
test.py
import MySQLdb import pyodbc print “TEST”
|