[Answered ]-Daphne ModuleNotFoundError: No module named

1👍

UPDATE: You’re not adding your project files to your Docker container during the build, so your container doesn’t have anything to run. You need to add them using a COPY or an ADD command.

It’s one of the basics of Docker. You should do some reading on what are Docker containers and how they work, or you can use an official example or follow one of a countless
Django + Docker tutorials available on the web.


I believe the issue lies within your Docker setup. Make sure you set WORKDIR in your Dockerfile.daphne and working_dir: in your docker-compose.yml to the same value, and you should be good.

Dockerfile:

FROM ...

WORKDIR /yourproject

COPY ...

RUN ...

...

...

docker-compose.yml:

  daphne:
    platform: linux/amd64
    build:
      context: .
      dockerfile: Dockerfile.daphne
    command: 'sh -c "daphne -b 0.0.0.0 -p 8000  apps.asgi:application"'
    restart: always
    working_dir: /yourproject

Leave a comment