Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Cannot start container with docker compose up

I am trying to Dockerize an application and it’s my first time. Have a Docker file inside the working directory:

# syntax=docker/dockerfile:1
FROM ubuntu:22.04

ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1

WORKDIR /

RUN apt-get update && apt-get install -y python3.10 python3-pip
RUN apt-get update && apt-get install -y git
RUN apt-get update && apt-get install -y libpq-dev python3-dev


COPY requirements.txt .

RUN pip install -r requirements.txt

COPY . .

and I have this docker-compose.yml file:

version: "1.1"

services:
  db:
    image: postgres:15-alpine
    volumes:
      - ./db:/var/lib/postgresql/data
    environment:
      - POSTGRES_USER=postgres
      - POSTGRES_PASSWORD=postgres
      - POSTGRES_DB=postgres
  backend:
    build: /
    ports:
      - "8000:8000"
    volumes:
      - ./:/backend
    env_file: .env
    command: python manage.py runserver 0.0.0.0:8000
    depends_on:
      - db
    restart: on-failure
  frontend:
    build: frontend/
    ports:
      - "3000:3000"
    volumes:
      - ../frontend/src:/frontend/src
    environment:
      - CHOKIDAR_USEPOLLING=true
    command: npm run dev
    depends_on:
      - backend

Every time I try and run docker compose build or docker compose up I get the following error:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

failed to solve: failed to read dockerfile: open /var/lib/docker/tmp/buildkit-mount3961901539/Dockerfile: no such file or directory

Why is it looking for the Dockerfile in that location if it is right here in the WORKDIR?

Is there a way to clear it and just start over with the dockerfile in the current directory?

>Solution :

For your backend service, you’re telling docker compose that the dockerfile is in the root directory with

build: /

It should be in the current directory, so change it to

build: .
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading