简体   繁体   English

在 docker 版本中安装 pip 后系统挂起

[英]System hangs after pip install in docker build

I am running the following Dockerfile我正在运行以下 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"]

I am trying to build an image of an ML model deployed on a Flask application.我正在尝试构建部署在 Flask 应用程序上的 ML model 的映像。 When I run the command my system hangs.当我运行命令时,我的系统挂起。

sudo docker build -t lhp .

I have to restart the system to rerun docker.我必须重新启动系统才能重新运行 docker。 The build execution stops at RUN pip3 install tensorflow==1.15 .构建执行在RUN pip3 install tensorflow==1.15处停止。 I have tried this multiple times using pip and pip3 but the error persists.我已经使用 pip 和 pip3 多次尝试,但错误仍然存在。 I have also tried replacing tensorflow with other python packages.我还尝试用其他 python 包替换 tensorflow。 The problem seems to be with pip and not with the particular python package.问题似乎出在 pip 而不是特定的 python package 上。 Please help me solve this.请帮我解决这个问题。 Following is a copy of my terminal.以下是我的终端的副本。

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

That's it.而已。 This is where it stops.这是它停止的地方。

Update更新

Here is the image history这是图像历史

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

install pip first (in this order in your dockerfile)首先安装 pip (在您的 dockerfile 中按此顺序)

RUN pip install -U pip

then run pip install (ex. for python3)然后运行 pip 安装(例如对于 python3)

RUN python3 -m pip install --no-cache-dir -r requirements.txt

So basically nothing worked.所以基本上没有任何效果。 I was facing the error due to some symlinks because I had shifted my Docker storage to another disk.由于某些符号链接,我遇到了错误,因为我已将 Docker 存储转移到另一个磁盘。 I uninstalled Docker and then eventually, Ubuntu.我卸载了 Docker,然后最终卸载了 Ubuntu。 Increased my Ubuntu partition size till it was big enough to store docker images.增加我的 Ubuntu 分区大小,直到它大到足以存储 docker 图像。 Reinstalled Ubuntu, Docker.重新安装 Ubuntu、Docker。 Now I live in peace with happy and successful docker builds.现在我与快乐和成功的 docker 构建和平相处。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM