A
A
Art0052020-11-17 19:52:00
Django
Art005, 2020-11-17 19:52:00

How to connect to a web application in a container through a browser?

I wanted to learn how to containerize web applications in Django.
I did everything through the tutorial.
I don’t know in which direction the problem is, so I tagged both tags.
As a result, everything starts normally in the container, but does not enter through my browser.
What and where did you miss?
Here is the dockerfile and dockercompose. If there is any other part that needs to be attached, let me know.

Dockerfile:
FROM python:3.8

ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1
WORKDIR /usr/src/dm_rest
RUN pip install Django
RUN pip install psycopg2
COPY . /usr/src/dm_rest
EXPOSE 8000

docker-compose.yml
version: '3.7'

services:
  db:
    image: library/postgres:10.1-alpine
    volumes:
      - postgres_data:/var/lib/postgresql/data/
  web:
    build: .
    command: python /usr/src/dm_rest/manage.py runserver 0.0.0.0:8000
    volumes:
    - .:/usr/src/dm_rest
    ports:
      - 8000:8000
    depends_on:
      - db

volumes:
  postgres_data:

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question