skip to Main Content

I’m trying to build my Docker image, but it’s taking forever. Even when I leave it to continue building, it fails after a long time. Here is my Dockerfile:

FROM ubuntu:24.04

# Install Python and pip
RUN apt-get update && apt-get install -y python3 python3-pip

WORKDIR /ner

COPY requirements.txt .

# Install required packages
RUN pip install -r requirements.txt --break-system-packages

COPY . .

I think the problem may be in the requirements file. Here is my requirements.txt:

tensorflow==2.16.1
pydantic-settings==2.2.1
transformers==4.40.1
fastapi==0.111.0
torchvision==0.18.0
torch==2.3.0
tqdm==4.66.2
numpy==1.26.4
scikit-learn==1.4.2
pandas==2.2.1

I tried to build it using this command:

docker build -t train .

The process is too slow and eventually fails. Could the issue be related to the size of these packages or their dependencies? Are there any optimizations I can apply to speed up the build process or resolve this issue?

2

Answers


  1. Chosen as BEST ANSWER

    I figured it out after many trials. The problem was that my C partition ran out of space, and building the image required more space. Once I made space for it, I restarted the build process, and it worked.


  2. You could try using python:3.8-slim instead of ubuntu:24.04. This will help speed up the build process and make debugging easier.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search