Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

run django in docker container

I'm trying to make a simple example of Django app running in docker container.

using this image https://hub.docker.com/_/django/ just for simplicity. Don't tell me please that i shouldn't use it in production :) app is very simple and i'm ok with using very basic Django server.

So, the problem is i'm always getting this error when trying to run the container image

C:\Users\slipo\PycharmProjects\simple_blog>docker run -p 8000:8000 my-blog
python: can't open file './manage.py runserver 0.0.0.0:8000 --settings=mysite.settings.prod': [Errno 2] No such file or directory

however, ./manage.py and mysite.settings.prod both definitely existing in container.

container creation log showing the file exists:

Step 7 : RUN ls -a
 ---> Running in 932ed2ad3e4c
.
..
.idea
Dockerfile
blog
manage.py
mysite
requirements.txt
templates
 ---> e7f938c1cbf2
Removing intermediate container 932ed2ad3e4c
Step 8 : CMD python ./manage.py runserver 0.0.0.0:8000 --settings=mysite.settings.prod
 ---> Running in f99bcafbc269
 ---> aca534e9ccb6
Removing intermediate container f99bcafbc269
Successfully built aca534e9ccb6

Dockerfile:

FROM django

EXPOSE 8000

ADD . /simple_blog
WORKDIR /simple_blog

RUN pip install -r requirements.txt
RUN pip install django-tinymce

RUN ls -a

CMD [ "python", "./manage.py runserver 0.0.0.0:8000 --settings=mysite.settings.prod" ]

Thank you.

like image 851
user1935987 Avatar asked Dec 16 '16 13:12

user1935987


2 Answers

can't open file './manage.py runserver 0.0.0.0:8000 --settings=mysite.settings.prod'

This is telling you that it is treating that entire string as a single filename.

I assume something like this works:

CMD [ "python", "./manage.py", "runserver", "0.0.0.0:8000", "--settings=mysite.settings.prod" ]
like image 171
RemcoGerlich Avatar answered Sep 22 '22 06:09

RemcoGerlich


Try to execute this code.

CMD [ "python", "../manage.py runserver 0.0.0.0:8080 --settings=my_site.settings.prd"
like image 42
Farhan Ansari Avatar answered Sep 21 '22 06:09

Farhan Ansari