Hello I’m trying to run a Django python project on docker but when I try to build the Dockerfile I get this error:
Note that only Django core commands are listed as settings are not properly configured (error: No module named ‘settings’).
This is the Dockerfile:
FROM python:3
ADD manage.py /
COPY requirements.txt /tmp
WORKDIR /tmp
RUN pip install -r requirements.txt
WORKDIR /
CMD [ "python", "manage.py" ]
However when I run the command
python manage.py
I get no errors and the settings file is loaded correctly… So I guess that my computer does know that the file exists but can’t acknowledge it through docker for some reason ?
This is my manage .py file:
import os
import sys
def main():
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'settings')
try:
from django.core.management import execute_from_command_line
except ImportError as exc:
raise ImportError(
"Couldn't import Django. Are you sure it's installed and "
"available on your PYTHONPATH environment variable? Did you "
"forget to activate a virtual environment?"
) from exc
execute_from_command_line(sys.argv)
if __name__ == '__main__':
main()
I’m a beginner and have been stuck on this for some days now, I looked for solutions online but they didn’t work… I will really appreciate your help!
Also I hope i’m posting in the correct forum