【问题标题】:Docker error The command non-zero code: 1 pythonDocker错误命令非零代码:1 python
【发布时间】:2017-06-11 13:13:24
【问题描述】:

我在尝试构建容器时遇到问题。错误是:

The command '/bin/sh -c pip install -r requirements.txt' returned a non-zero code: 1

我不知道为什么,我按照文档中的代码进行操作,但总是出错。

Dockerfile

FROM python:2.7-slim
#
# # Set the working directory to /app
WORKDIR /app
#
# # Copy the current directory contents into the container at /app
ADD . /app
#
# # Install any needed packages specified in requirements.txt
RUN pip install -r requirements.txt
#
# # Make port 80 available to the world outside this container
EXPOSE 80
#
# # Define environment variable
ENV NAME World
#
# # Run app.py when the container launches
CMD ["python", "app.py"]

【问题讨论】:

  • 手动附加到容器并运行相同的命令
  • 我更新问题中的dockerfile
  • 而当你运行 docker build 时,需求文件在哪里?
  • 与Dockerfile和app.py在同一个文件夹中
  • 我检查了我的 requirements.txt,在 docker 文档上只添加了 python 和 Redis,我尝试即兴创作,我在 requirements.txt 中添加了scrapy。在我删除scrapy后,它正在工作。你能解释一下,为什么?

标签: python docker pip dockerfile


【解决方案1】:

文件位置似乎有问题,尝试给出您在 dockerfile 中引用的文件的绝对路径

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-01-30
    • 1970-01-01
    • 1970-01-01
    • 2020-05-24
    • 1970-01-01
    • 1970-01-01
    • 2014-02-26
    • 1970-01-01
    相关资源
    最近更新 更多