【发布时间】:2020-07-17 13:39:49
【问题描述】:
我正在运行以下 Dockerfile
FROM python:3.6.9
WORKDIR /app
COPY . /app
# install dependencies
RUN pip3 install tensorflow==1.15
RUN pip3 install -r requirements.txt
# define the port number
EXPOSE 5000
# run
CMD ["python3", "./index.py"]
我正在尝试构建部署在 Flask 应用程序上的 ML 模型的图像。当我运行该命令时,我的系统会挂起。
sudo docker build -t lhp .
我必须重新启动系统才能重新运行 docker。构建执行在RUN pip3 install tensorflow==1.15 处停止。我已经使用 pip 和 pip3 多次尝试过,但错误仍然存在。我也尝试用其他 python 包替换 tensorflow。问题似乎出在 pip 而不是特定的 python 包。请帮我解决这个问题。以下是我的终端的副本。
aishwarya@aishwarya-ThinkPad-W540:/media/aishwarya/2E068D88068D522F/lhp$ sudo docker build -t lhpoc8 .
Sending build context to Docker daemon 452.5MB
Step 1/7 : FROM python:3.6.9
---> 5bf410ee7bb2
Step 2/7 : WORKDIR /app
---> Running in fefe94814764
Removing intermediate container fefe94814764
---> e261c29f7c96
Step 3/7 : COPY . /app
---> babae5a3fee8
Step 4/7 : RUN pip3 install tensorflow==1.15
---> Running in 7e4d9d7e5353
就是这样。这是它停止的地方。
更新
这是图像历史记录
aishwarya@aishwarya-ThinkPad-W540:/media/aishwarya/2E068D88068D522F/lhp$ sudo docker image history 1c7f12b2e283
IMAGE CREATED CREATED BY SIZE COMMENT
1c7f12b2e283 23 minutes ago /bin/sh -c #(nop) COPY dir:235abf6dd10dddd25… 452MB
88bcbf8e9815 23 minutes ago /bin/sh -c #(nop) WORKDIR /app 0B
5bf410ee7bb2 4 months ago /bin/sh -c #(nop) CMD ["python3"] 0B
<missing> 4 months ago /bin/sh -c set -ex; wget -O get-pip.py "$P… 6.25MB
<missing> 4 months ago /bin/sh -c #(nop) ENV PYTHON_GET_PIP_SHA256… 0B
<missing> 4 months ago /bin/sh -c #(nop) ENV PYTHON_GET_PIP_URL=ht… 0B
<missing> 4 months ago /bin/sh -c #(nop) ENV PYTHON_PIP_VERSION=19… 0B
<missing> 4 months ago /bin/sh -c cd /usr/local/bin && ln -s idle3… 32B
<missing> 4 months ago /bin/sh -c set -ex && wget -O python.tar.x… 86.2MB
<missing> 4 months ago /bin/sh -c #(nop) ENV PYTHON_VERSION=3.6.9 0B
<missing> 4 months ago /bin/sh -c #(nop) ENV GPG_KEY=0D96DF4D4110E… 0B
<missing> 4 months ago /bin/sh -c apt-get update && apt-get install… 17.1MB
<missing> 4 months ago /bin/sh -c #(nop) ENV LANG=C.UTF-8 0B
<missing> 4 months ago /bin/sh -c #(nop) ENV PATH=/usr/local/bin:/… 0B
<missing> 4 months ago /bin/sh -c set -ex; apt-get update; apt-ge… 510MB
<missing> 4 months ago /bin/sh -c apt-get update && apt-get install… 145MB
<missing> 4 months ago /bin/sh -c set -ex; if ! command -v gpg > /… 17.5MB
<missing> 4 months ago /bin/sh -c apt-get update && apt-get install… 16.5MB
<missing> 4 months ago /bin/sh -c #(nop) CMD ["bash"] 0B
<missing> 4 months ago /bin/sh -c #(nop) ADD file:9b7d9295bf7e8307b… 114MB
【问题讨论】:
-
你确定它没有挂在下一行:
RUN pip3 install -r requirements.txt?这似乎更合理 -
不。我交换了 2 个
RUN pip3命令,错误总是出现在先出现的那个。 -
那么问题似乎出在对
pip3命令的调用中。它是可访问的和存在的吗?例如在我的机器上也安装了perlpip指的是perl脚本,我需要使用完整路径来访问python的pip。类似的情况可能在这里 -
如何检查它是否可访问或存在? pip3不是和父python3.6.9镜像一起来的吗?
-
有时需要额外设置pip.pypa.io/en/stable/installing
标签: python docker pip dockerfile docker-build