My project directory looks like this the following. As you can see, I have structured the directory myproject to be seen as a Python package.
. |-- Dockerfile |-- README.md |-- requirements.txt `-- myproject |-- __init__.py |-- __main__.py |-- __pycache__ |-- config.py |-- db.py |-- env.py |-- filehandle.py |-- main.py |-- pepkeys |-- test.py `-- util.py
On my host system, I can run the package like this without any issue:
python -m myproject
However, after I build my Docker image successfully, I cannot run the container, this is the error that I get:
/usr/local/bin/python: No module named myproject
This is how my Dockerfile looks like, it is relatively simple.
FROM python:3.8.5-alpine COPY . /app RUN pip install -r /app/requirements.txt WORKDIR /app CMD ["python", "-m myproject"]
What do I need to do to be able to run my Python project as a package inside a Docker container?