Home > database >  My container is being exiting itself while creating , What is the solution to solve this issue?
My container is being exiting itself while creating , What is the solution to solve this issue?

Time:02-25

Am trying to build a docker image for my django webapp and upload it to the docker hub . Then pull that image using kubernetes . Am in trouble creating container out of my docker image , Whenever I create my container is exiting itself, Am I doing any mistake while creating a Dockerfile ?

DOCKER FILE :

FROM python:3

ENV PYTHONDONTWRITEBYTECODE=1

ENV PYTHONUNBUFFERED=1

WORKDIR /django-app

COPY requirments.txt /django-app/

RUN pip install -r requirments.txt

ADD . /django-app

COPY . /django-app/

CMD [ "python", "./manage.py runserver 0.0.0.0:8000" ]

FILES

REQUIRMENTS FILE(requirments.txt)

Django>=4.0
psycopg2>=2.8

Container exiting:

enter image description here

While I checked my container logs , It shows "python: can't open file '/django-app/./manage.py runserver 0.0.0.0:8000': [Errno 2] No such file or directory"

enter image description here

CodePudding user response:

By doing

CMD [ "python", "./manage.py runserver 0.0.0.0:8000" ]

Python will look for a file called ./manage.py runserver 0.0.0.0:8000 which doesn't exist. You need to split the parameters up so it becomes

CMD [ "python", "./manage.py", "runserver", "0.0.0.0:8000" ]

You can also use the simpler syntax of

CMD python ./manage.py runserver 0.0.0.0:8000

if you prefer.

CodePudding user response:

There was a problem with the path when starting

CMD [ "python", "/django-app/manage.py", "runserver", "0.0.0.0:8000" ]
  • Related