python - 容器 : volume dockerfile does not work

标签 python docker

我无法从我的项目中启动新的 jupyter-notebook。
在我的 dockerfile 下面。

FROM python:3.9.0
ARG WORK_DIR=/opt/dir1
RUN apt-get update && apt-get install cron -y && apt-get install -y default-jre
# Install python libraries
COPY requirements.txt /tmp/requirements.txt
RUN pip install --upgrade pip && pip install -r /tmp/requirements.txt
WORKDIR $WORK_DIR
EXPOSE 8888
# Copy etl code
# copy code on container under your workdir "/opt/dir1"
COPY . .
ENTRYPOINT ["sh", "-c"]
CMD ["jupyter-notebook --ip 0.0.0.0 --no-browser --allow-root]    
VOLUME /home/data/dir1/
然后在我的终端我做了
#build
docker build -t my-python-app .
#run
docker run -it -p 8888:8888 my-python-app
#in container i did
jupyter notebook --ip 0.0.0.0 --no-browser --allow-root 
我认为我的 VOLUME 不起作用,因为当我在容器文件中进行修改时,主机/home/data/dir1/中没有任何 react 。
有谁知道为什么以及如何解决它?

最佳答案

您可以使用,docker run -it /bin/bash (image name)并尝试导航到您为该卷设置的文件夹,查看是否发生错误并检查权限。
使用卷时,请检查您可以访问该文件夹的主机系统。然后检查您是哪个用户,Docker 允许将您的 USER_ID 和 GROUP_ID 解析到容器。
从那里您可以使用与您在主机系统上相同的用户和组。如果您想访问主机系统上的同一个文件夹,您可能会遇到权限问题。
有关这方面的更多信息,请访问以下网页。
https://jtreminio.com/blog/running-docker-containers-as-current-host-user/

关于python - 容器 : volume dockerfile does not work,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68957082/

相关文章:

python - 为什么 PyCharm 不允许在方法命名中使用大写字母?

docker - NodePort 错误连接被拒绝(Docker Desktop、Windows、Kubernetes)

docker - 中间Docker镜像是否占用磁盘空间?

python - 进行预测 Sagemaker Pytorch

python - Dask 中间结果

python - 如何从 HDF5 文件中提取单个 JPEG 图像

docker - Openshift Jenkins(2)— docker :未找到命令

asp.net - 将多个容器上载到Azure容器注册表

php - 在 Mac OS 上设置 docker - 无法安装 php-intl

python - 使用 python 调试器 (pdb) 时调试 cython 代码 (.pyx) - 最佳实践