如何安装包到docker的python?
例如,我需要lmxl。在 docker 的 django 应用程序中,我运行 pip install lxml 并且终端响应已经满足要求(因为它安装在 OS X python 2.7 包中),但实际上它没有安装在 docker 的 python 包中。
那么,如何将pip install something应用到docker上呢?
请您参考如下方法:
正确的方法是更新项目的requirements.txt文件。
# requirements.txt
# .. other requirements
lxml
在(运行 apt-get update .....)之后将 lxml 依赖项添加到您的 Dockerfile
RUN apt-get install -y python-dev libxml2-dev libxslt1-dev zlib1g-dev
现在构建并运行。使用
docker-compose build
docker-compose up
或
docker-compose up --build
