python - 在 docker build 中安装 pip 后系统挂起
问题描述
我正在运行以下 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
解决方案
首先安装 pip(在您的 dockerfile 中按此顺序)
RUN pip install -U pip
然后运行 pip install (例如python3)
RUN python3 -m pip install --no-cache-dir -r requirements.txt
推荐阅读
- android - 反应填充所有手机屏幕尺寸的本机网格,滑动时将消失
- javascript - 选择所有选项 A 带有 javascript 的单选按钮
- tensorflow - 将张量变量(非常数)转换为 numpy 数组?
- r - 安装最新的苏打水版本
- gcc - 如何修复“不支持的 GNU 版本!gcc 版本晚于 6...”
- javascript - 最佳游戏手柄轮询频率是多少?
- html - 在刀片中水平对齐表格 td
- prometheus - 了解 PromQL 聚合的结构?
- perl - 在我打印其他内容之前,在 Perl 中打印一个点不会出现在屏幕上
- c++ - Pow() 真的需要 cmath 标头还是 iostream 是否包含 cmath?