Reputation: 108
I'm setting up a django server application on docker. docker runs the container well but the command to run django is not taking by docker.
I've already gone through few youtube videos but none of them worked for me
Dockerfile
FROM python:3.6-stretch
MAINTAINER ***
ENV PYTHONBUFFERED 1
COPY ./requirements.txt /requirements.txt
RUN pip install -r /requirements.txt
RUN mkdir /specfolder
WORKDIR /specfolder
COPY ./myfolder /specfolder
EXPOSE 8000
CMD ["python", "manage.py runserver"]
i've tried placing the command under docker-compose.yml file under
commands: sh -c "python manager.py runserver"
but none of them worked
docker-compose.yml file
version: "3"
services:
myapp:
build:
context: .
ports:
- "8000:8000"
volumes:
- ./myfolder:/specfolder
requriements.txt
django==2.2.4
pandas
xlrd
xlsxwriter
as of now under kinematics i am getting the python shell
Type "help", "copyright", "credits" or "license" for more information.
>>> 2019-08-31T13:34:51.844192800Z Python 3.6.9 (default, Aug 14 2019,
13:02:21)
[GCC 6.3.0 20170516] on linux
unable to access the 127.0.0.1:8000/myapp/login in the browser.
Upvotes: 0
Views: 2377
Reputation: 1767
You need to make changes in your runserver command. Change it to
python manage.py runserver 0.0.0.0:8000
Your Dockerfile will be something like this
# other command
CMD ["python", "manage.py", "runserver", "0.0.0.0:8000"]
Make changes accordingly if you are using Dockerfile or docker-compose.
Upvotes: 1
Reputation: 57640
I see 2 problems in your implementation.
In Dockerfile
you have, CMD ["python", "manage.py runserver"]
. It should be CMD ["python", "manage.py", "runserver"]
In compose file commands: sh -c "python manager.py runserver"
should be commands: python manager.py runserver
.
CMD
should be removed from Dockerfile
Upvotes: 0