需求.txt未安装在Docker容器中
我有以下dockerfile
FROM jupyter/scipy-notebook
COPY . ./work
COPY setup.py /work
RUN pip install --upgrade pip && pip install -e .
RUN pip install -r ./work/requirements.txt
COPY src /work/src
WORKDIR /work
,以下docker-compose.yml
version: '3.7'
networks:
ling172:
services:
jupyter:
image: jupyter/datascience-notebook:r-4.0.3
environment:
- JUPYTER_TOKEN=password
- JUPYTER_ENABLE_LAB=yes
volumes:
- .:/home/jovyan/work
- ./notebooks:/home/jovyan/work
- ./src:/home/jovyan/work
ports:
- 7777:8888
container_name: almond_analysis
networks:
- ling172
和以下要求。txt文件
openpyxl==3.0.10
项目结构为
almond_analysis:
notebooks:
data_exploration.ipynb
src:
__init__.py
plots.py
.gitignore
docker-compose.yml
Dockerfile
README.md
requirements.txt
setup.py
,设置文件是
from setuptools import find_packages, setup
import sys
import os
sys.path.insert(0, os.path.abspath( os.path.dirname(__file__)))
requirements_path="requirements.txt"
with open(requirements_path) as requirements_file:
requirements = requirements_file.read().splitlines()
setup(
name="almond_analysis",
version="0.0.1",
description = "Almond analysis",
long_description="Analysing yield with Python.",
author= "George N",
packages= find_packages(),
install_requires=requirements,
classifiers=[
"Programming Language :: Python :: 3"
],
python_requires =">= 3.0.*",
)
问题是,一旦我打开data_exploration。 ipynb
笔记本OpenPyXl
尚未安装软件包,这意味着尚未读取unignts.txt
文件。我怀疑这是因为我正在使用命令docker组成-d
启动容器,这意味着我没有重建图像,这意味着未读取Dockerfile。因此,我如下修改了docker-compose.yml文件(即我添加了构建:。
)
version: '3.7'
networks:
ling172:
services:
jupyter:
build: .
image: jupyter/datascience-notebook:r-4.0.3
environment:
- JUPYTER_TOKEN=password
- JUPYTER_ENABLE_LAB=yes
volumes:
- .:/home/jovyan/work
- ./notebooks:/home/jovyan/work
- ./src:/home/jovyan/work
ports:
- 7777:8888
container_name: almond_analysis
networks:
- ling172
,但没有运气。
有人知道如何成功安装unignts.txt
中的软件包吗?
I have got the following Dockerfile
FROM jupyter/scipy-notebook
COPY . ./work
COPY setup.py /work
RUN pip install --upgrade pip && pip install -e .
RUN pip install -r ./work/requirements.txt
COPY src /work/src
WORKDIR /work
and the following docker-compose.yml
version: '3.7'
networks:
ling172:
services:
jupyter:
image: jupyter/datascience-notebook:r-4.0.3
environment:
- JUPYTER_TOKEN=password
- JUPYTER_ENABLE_LAB=yes
volumes:
- .:/home/jovyan/work
- ./notebooks:/home/jovyan/work
- ./src:/home/jovyan/work
ports:
- 7777:8888
container_name: almond_analysis
networks:
- ling172
and the following requirements.txt file
openpyxl==3.0.10
The project structure is
almond_analysis:
notebooks:
data_exploration.ipynb
src:
__init__.py
plots.py
.gitignore
docker-compose.yml
Dockerfile
README.md
requirements.txt
setup.py
and the setup file is
from setuptools import find_packages, setup
import sys
import os
sys.path.insert(0, os.path.abspath( os.path.dirname(__file__)))
requirements_path="requirements.txt"
with open(requirements_path) as requirements_file:
requirements = requirements_file.read().splitlines()
setup(
name="almond_analysis",
version="0.0.1",
description = "Almond analysis",
long_description="Analysing yield with Python.",
author= "George N",
packages= find_packages(),
install_requires=requirements,
classifiers=[
"Programming Language :: Python :: 3"
],
python_requires =">= 3.0.*",
)
The problem is that once I open the data_exploration.ipynb
notebook the openpyxl
package has not been installed, which means that the requirements.txt
file has not been read. I suspect that this is because I am starting the container with the command docker compose up -d
which means that I am not rebuilding the image, which means that the Dockerfile is not read. So I modified the docker-compose.yml file as follows (ie I added build: .
)
version: '3.7'
networks:
ling172:
services:
jupyter:
build: .
image: jupyter/datascience-notebook:r-4.0.3
environment:
- JUPYTER_TOKEN=password
- JUPYTER_ENABLE_LAB=yes
volumes:
- .:/home/jovyan/work
- ./notebooks:/home/jovyan/work
- ./src:/home/jovyan/work
ports:
- 7777:8888
container_name: almond_analysis
networks:
- ling172
but without luck.
Does anyone know how to install, successfully, the packages in requirements.txt
?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
通过键入
docker-compose -d-build
与第二个docker-compose.yml
文件和所有其他文件(如@dallyger建议) )。Solved by typing
docker-compose up -d --build
with the seconddocker-compose.yml
file and all other files as shown in the question (as suggested by @dallyger).