【发布时间】:2016-06-26 04:31:01
【问题描述】:
我想在docker中部署我的python项目,我在requirments.txt中写了lxml>=3.5.0,因为项目需要lxml。这是我的停靠文件:
FROM gliderlabs/alpine:3.3
RUN set -x \
&& buildDeps='\
python-dev \
py-pip \
build-base \
' \
&& apk --update add python py-lxml $buildDeps \
&& rm -rf /var/cache/apk/* \
&& mkdir -p /app
ENV INSTALL_PATH /app
WORKDIR $INSTALL_PATH
COPY requirements-docker.txt ./
RUN pip install -r requirements.txt
COPY . .
RUN apk del --purge $buildDeps
ENTRYPOINT ["celery", "-A", "tasks", "worker", "-l", "info", "-B"]
我在将它部署到 docker 时得到了这个:
*********************************************************************************
Could not find function xmlCheckVersion in library libxml2. Is libxml2 installed?
*********************************************************************************
error: command 'gcc' failed with exit status 1
----------------------------------------
Rolling back uninstall of lxml
我虽然是因为'python-dev'和'python-lxml',然后我这样编辑了dockfile:
WORKDIR $INSTALL_PATH
COPY requirements-docker.txt ./
RUN apt-get build-dev python-lxml
RUN pip install -r requirements.txt
它不起作用,我得到另一个错误:
---> Running in 73201a0dcd59
/bin/sh: apt-get: not found
如何在 docker 中正确安装 lxml?
【问题讨论】:
-
你用的是alpine,所以可能是
apk add而不是apt-get -
@user2915097 谢谢!我将其更改为
apk add python-dev py-lxml,它返回错误:error: command 'gcc' failed with exit status 1。我不知道如何安装 lxml
标签: python docker lxml dockerfile