0

I want to dockerize the following application, however, for some reason, I can't run it in docker, but it works on my local machine, the file structure goes as follows

Dockerfile
requirements.txt
src
├── database
├── logs
└── scrapers
    ├── __init__.py
    └── taskmanager.py

Here're the contents of my Dockerfile

FROM python:3.10-slim

WORKDIR app

COPY requirements.txt requirements.txt
RUN pip install -r requirements.txt

COPY . .

CMD ["python", "-m", "src.scrapers.taskmanager"]

For some reason, when I run the application from the root folder on my Windows machine via "python -m src.scrapers.taskmanager" it works, but that's not the case with Docker. Any help?

/usr/local/bin/python: Error while finding module specification for 'src.scrapers.taskmanager' (ModuleNotFoundError: No module named 'src.scrapers')
3
  • Since you don't need to copy Dockerfile and you've already copied requirements.txt, can you try replacing the COPY with COPY src src? Commented Feb 22, 2023 at 1:54
  • 2
    Is there a __init__.py in the src folder? That's necessary to make it a module. Commented Feb 22, 2023 at 2:19
  • try CMD ["python", "src/scrapers/taskmanager.py"] Commented Feb 22, 2023 at 4:04

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.