Bruno Cerecetto
Bruno Cerecetto

Reputation: 820

Docker compose - python: can't open file 'manage.py': [Errno 2] No such file or directory

I want to create with docker-compose 2 Docker containers. 1 for DB (Postgres) and 1 for web (Django). Here are my files

docker-compose.yml

version: '3.7'

services:
  api:
    build: ./portal
    command: python manage.py runserver 0.0.0.0:8000
    volumes:
      - ./app/:/usr/src/app/
    ports:
      - 8000:8000
    env_file:
      - ./portal/.env
  db:
    image: postgres:13p.0-alpine
    volumes:
      - postgres_data:/var/lib/postgresql/data/
    environment:
      - POSTGRES_USER=portal
      - POSTGRES_PASSWORD=portal
      - POSTGRES_DB=sterling

volumes:
  postgres_data:

Dockerfile

# pull official base image
FROM python:3.8.3-alpine

# set work directory
WORKDIR /usr/src/app

# set environment variables
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1

# install dependencies
RUN pip install --upgrade pip

RUN apk add --no-cache \
    build-base cairo-dev cairo cairo-tools \
    # pillow dependencies
    jpeg-dev zlib-dev freetype-dev lcms2-dev openjpeg-dev tiff-dev tk-dev tcl-dev

RUN pip install "flask==1.0.1" "CairoSVG==2.1.3"

COPY ./requirements/base.txt .

RUN \
 apk add --no-cache python3 postgresql-libs && \
 apk add --no-cache --virtual .build-deps gcc python3-dev \
 libxml2 libxml2-dev musl-dev postgresql-dev && \
 apk add libxslt-dev && \ 
 python3 -m pip install -r base.txt --no-cache-dir && \
 apk --purge del .build-deps

# copy project
COPY . .

when i run docker-compose up it throws me the following error:

web_1  | python: can't open file 'manage.py': [Errno 2] No such file or directory

Do you have an idea why docker-compose doesn't find my file when starting?

Upvotes: 0

Views: 1530

Answers (1)

Ashok
Ashok

Reputation: 3611

Remove volumes from docker-compose.yml and build again.

There is an issue with docker-compose on ubuntu. it can't mount the volume. And as I can see you want to mount . to /usr/src/app

and make sure you build the image again after you update the code.

Upvotes: 1

Related Questions