After running docker-compose up
,
Starting docker_django ... done
Attaching to docker_django
docker_django | Watching for file changes with StatReloader
docker_django | Performing system checks...
docker_django | System check identified no issues (0 silenced).
docker_django | February 12, 2020 - 07:26:35
docker_django | Django version 3.0.3, using settings 'backend.settings'
docker_django | Starting development server at http://127.0.0.1:8000/
docker_django | Quit the server with CONTROL-C.
when i connect to http://127.0.0.1:8000/ it shows this There is no problem / error running the docker-compose command but only when visiting the site.
Im using ubuntu 19.10 and the project has django v3.
Dockerfile
FROM python:3
ENV PYTHONUNBUFFERED 1
RUN mkdir /code
WORKDIR /code
COPY . /code/
RUN pip install -r requirements.txt
docker-compose.yml
version: '3'
services:
web:
build: .
container_name: docker_django
command: python manage.py runserver
volumes:
- .:/code
ports:
- "8000:8000"
Your application only listens to requests coming from localhost, which in case of a container are requests coming from inside the container.
Try this compose file:
version: '3'
services:
web:
build: .
container_name: docker_django
command: python manage.py runserver 0.0.0.0:8000
volumes:
- .:/code
ports:
- "8000:8000"
corrected typo for port number as suggested
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With