Search code examples
dockermachine-learningcomputer-visiondockerfilecomputer-science

Building the docker image results in error while running "docker build -t file-name ."


I am working on a ml model which I am trying to containerise using Docker, While running the command for docker build -t <file-name> <location>

the below is the docker file.

FROM python:3.11-alpine
COPY . /app
WORKDIR /app 
RUN pip install -r requirements.txt 
CMD streamlit run viz_app.python

And below is the error I'm getting.

22.34   note: This error originates from a subprocess, and is likely not a problem with pip.
22.34 error: subprocess-exited-with-error
22.34 
22.34 × pip subprocess to install build dependencies did not run successfully.
22.34 │ exit code: 1
22.34 ╰─> See above for output.
22.34 
22.34 note: This error originates from a subprocess, and is likely not a problem with pip.
22.36 
22.36 [notice] A new release of pip is available: 23.0.1 -> 23.3.1
22.36 [notice] To update, run: pip install --upgrade pip
------
Dockerfile:4
--------------------
   2 |     COPY . /app
   3 |     WORKDIR /app 
   4 | >>> RUN pip install -r requirements.txt 
   5 |     CMD streamlit run viz_app.python
--------------------
ERROR: failed to solve: process "/bin/sh -c pip install -r requirements.txt" did not complete successfully: exit code: 1

I've tried to solve the particular issue using the approaches below.

  • I tried upgrading the pip by mentioning "RUN pip install --upgrade pip"
  • trying to install different version of packages of the requirement file also.

For further reference I'm adding the packages of requirement.txt file below.

numpy
pandas
streamlit
scikit-learn
matplotlib
opencv-python
tensorflow
segmentation-models

Solution

  • According to other topics it looks like numpy and alpine are not working the best together : Alpine and numpy

    Is the alpine necessary ? Else you can use a basic python:3.11 image from docker and this should work correctly.

    Moreover, you should give versions in your requirements.txt (for example pandas==2.0). This will alow you to have more control on the image / environment you are building in docker