Aishwarya Harpale
Aishwarya Harpale

Reputation: 419

System hangs after pip install in docker build

I am running the following 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. When I run the command my system hangs.

sudo docker build -t lhp .

I have to restart the system to rerun docker. The build execution stops at RUN pip3 install tensorflow==1.15. I have tried this multiple times using pip and pip3 but the error persists. I have also tried replacing tensorflow with other python packages. The problem seems to be with pip and not with the particular 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

Upvotes: 4

Views: 6484

Answers (2)

Aishwarya Harpale
Aishwarya Harpale

Reputation: 419

So basically nothing worked. I was facing the error due to some symlinks because I had shifted my Docker storage to another disk. I uninstalled Docker and then eventually, Ubuntu. Increased my Ubuntu partition size till it was big enough to store docker images. Reinstalled Ubuntu, Docker. Now I live in peace with happy and successful docker builds.

Upvotes: 1

None
None

Reputation: 602

install pip first (in this order in your dockerfile)

RUN pip install -U pip

then run pip install (ex. for python3)

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

Upvotes: 1

Related Questions