When running docker-compose up --build
I'm constantly getting this error.
=> [web internal] load build definition from Dockerfile 0.0s
=> => transferring dockerfile: 1.58kB 0.0s
=> [web internal] load .dockerignore 0.0s
=> => transferring context: 279B 0.0s
=> [web internal] load metadata for docker.io/library/python:3.8 0.8s
=> CANCELED [web 1/14] FROM docker.io/library/python:3.8@sha256:7a82536f5a2895b70416ccaffc49e6469d11ed8d9bf6bcf 0.3s
=> => resolve docker.io/library/python:3.8@sha256:7a82536f5a2895b70416ccaffc49e6469d11ed8d9bf6bcfc52328faeae7c77 0.2s
=> => sha256:795c73a8d985b6d1b7e5730dd2eece7f316ee2607544b0f91841d4c4142d9448 7.56kB / 7.56kB 0.0s
=> => sha256:7a82536f5a2895b70416ccaffc49e6469d11ed8d9bf6bcfc52328faeae7c7710 1.86kB / 1.86kB 0.0s
=> => sha256:129534c722d189b3baf69f6e3289b799caf45f75da37035c854100852edcbd7d 2.01kB / 2.01kB 0.0s
=> CANCELED [web internal] load build context 0.1s
=> => transferring context: 26.00kB 0.0s
failed to solve: Canceled: context canceled
This has been happening since yesterday, before my images would build and my application would run just fine.
I'm quite lost as to what is going wrong, I've used python3.8
and python3.9
without issues before. Below is my dockerfile and docker-compose.
# Use an official Python runtime as the base image
FROM python:3.8
# Set environment variables
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1
ENV NODE_ENV production
# Create and set the working directory
WORKDIR /app
# Install system dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
default-mysql-client \
software-properties-common \
curl \
gnupg \
&& curl -fsSL https://deb.nodesource.com/gpgkey/nodesource.gpg.key | gpg --dearmor -o /usr/share/keyrings/nodesource.gpg \
&& echo "deb [signed-by=/usr/share/keyrings/nodesource.gpg] https://deb.nodesource.com/node_20.x bullseye main" | tee /etc/apt/sources.list.d/nodesource.list \
&& apt-get update && apt-get install -y nodejs \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# Verify that Node.js and npm are installed
RUN node --version
RUN npm --version
# Install Python dependencies
COPY requirements.txt .
RUN pip install --upgrade pip && \
pip install -r requirements.txt
# Install Tailwind CSS and its peer dependencies
COPY package.json package-lock.json ./
RUN npm install
# Copy the current directory contents into the container
COPY . .
# Build the Tailwind CSS
RUN npm run build:css
RUN npm run watch:css
COPY entrypoint.sh ./entrypoint.sh
RUN chmod +x ./entrypoint.sh
ENTRYPOINT ["./entrypoint.sh"]
# The main command to run when the container starts
CMD ["gunicorn", "--bind", ":8000", "bmlabs.wsgi:application"]
Docker-compose
services:
db:
image: mysql:5.7
volumes:
- db_data:/var/lib/mysql
restart: always
environment:
MYSQL_ROOT_PASSWORD:
MYSQL_DATABASE:
MYSQL_USER:
MYSQL_PASSWORD:
networks:
- backend
web:
build: .
volumes:
- .:/app
- static_volume:/app/staticfiles
- media_volume:/app/mediafiles
depends_on:
- db
networks:
- backend
expose:
- "8000"
nginx:
image: nginx:alpine
ports:
- "80:80"
volumes:
- ./nginx/nginx.conf:/etc/nginx/nginx.conf:ro
- ./nginx/bmlabs.conf:/etc/nginx/conf.d/bmlabs.conf:ro
- static_volume:/app/staticfiles
- media_volume:/app/mediafiles
depends_on:
- web
networks:
- backend
networks:
backend:
volumes:
db_data:
cache_data:
static_volume:
media_volume:
I am on Windows 10.
Altough downgrading docker worked, the actual problem was that I didn't exclude node_modules in Dockerignore. I had been running the containers fine for quite a long time.
After purging all containers and images and adding the node_modules/
line to my .dockerignore
it fixed it.
I'm guessing the error had to do with the amount of files inside certain directories.