需要先安装依赖包postgresql-dev
、gcc
、python3-dev
、musl-dev
:
1 2 3
| apk update apk add postgresql-dev gcc python3-dev musl-dev pip install psycopg2
|
当然也可以先做一个基础镜像:
1 2 3 4 5
| FROM python:3.5-alpine
RUN apk update && apk add postgresql-dev gcc python3-dev musl-dev
CMD ["python3"]
|
在国内也可以使用aliyun的镜像源:
1 2 3 4 5 6 7
| FROM python:3.5-alpine
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories \ && apk update \ && apk add postgresql-dev gcc python3-dev musl-dev
CMD ["python3"]
|