【问题标题】:Dockerfile fails when installing a python local package with permission denied安装权限被拒绝的 python 本地包时 Dockerfile 失败
【发布时间】:2020-02-25 15:06:29
【问题描述】:

我有这个 Dockerfile:

FROM jupyter/scipy-notebook

ADD /dist /our_controller/dist
ADD /wheelhouse /our_controller/wheelhouse
COPY setup.py /our_controller
COPY package.py /our_controller
COPY README.md /our_controller
WORKDIR /app
# add our_controller to python 3.7
RUN python3 -m pip install -e ../our_controller/ --user

我从项目的基本目录中使用此命令docker build -f ./Dockerfile .。我之前使用python3 setup.py package 创建了 ./dist 目录内容,所有依赖项都作为 *.whl 文件存在于 ./wheelhouse 目录中,由 package.py 生成。

我收到此错误:

docker build -f ./Dockerfile .
Sending build context to Docker daemon  810.4MB
Step 1/8 : FROM jupyter/scipy-notebook
 ---> 19db0c85c56d
Step 2/8 : ADD /dist /our_controller/dist
 ---> Using cache
 ---> 018e642c5681
Step 3/8 : ADD /wheelhouse /our_controller/wheelhouse
 ---> Using cache
 ---> 94bc3eae623a
Step 4/8 : COPY setup.py /our_controller
 ---> Using cache
 ---> 1df4893a77bc
Step 5/8 : COPY package.py /our_controller
 ---> Using cache
 ---> 70873a32d702
Step 6/8 : COPY README.md /our_controller
 ---> Using cache
 ---> b79ba7f82b77
Step 7/8 : WORKDIR /app
 ---> Using cache
 ---> 98d117a270bc
Step 8/8 : RUN python3 -m pip install -e ../our_controller/ --user
 ---> Running in 7bfa140ca14e
Obtaining file:///our_controller
    ERROR: Command errored out with exit status 1:
     command: /opt/conda/bin/python3 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/our_controller/setup.py'"'"'; __file__='"'"'/our_controller/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info
         cwd: /our_controller/
    Complete output (3 lines):
    running egg_info
    creating ourcontroller.egg-info
    error: could not create 'ourcontroller.egg-info': Permission denied
    ----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
The command '/bin/sh -c python3 -m pip install -e ../our_controller/ --user' returned a non-zero code: 1

项目目录中的所有文件都归用户所有,不归根用户所有。我过去创建了几个 Dockerfile,但安装了一个我以前没有尝试过的本地包。我显然错过了一些东西。谁能指出来?

【问题讨论】:

    标签: python-3.x docker dockerfile


    【解决方案1】:

    我也遇到了这个问题。我最终构建了一个轮子,然后在图像中添加并安装了轮子。

    本地

    python setup.py bdist_wheel
    

    Dockerfile

    FROM jupyter/scipy-notebook
    RUN conda install ipdb lxml -y
    ADD dist/my_package-0.0.1-py3-none-any.whl my_package-0.0.1-py3-none-any.whl
    RUN pip install my_package-0.0.1-py3-none-any.whl
    
    

    【讨论】:

      猜你喜欢
      • 2016-02-21
      • 1970-01-01
      • 1970-01-01
      • 2012-11-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-10-06
      • 2021-12-20
      相关资源
      最近更新 更多