MM01K
MM01K

Reputation: 11

Trying to run a container on docker but can not access the website of the application we created

We've been using python3 and Docker as our framework. Our main issue is that while we try to run the docker container it redirects us to the browser but the website can not be reached. But it is working when we run the commands python manage.py runserver manualy from the terminal of VS code

here is the docker-compose.yml file

version: "2.12.2"

services:
web:
tty: true
build:
dockerfile: Dockerfile
context: .
command: bash -c "cd happy_traveller && python manage.py runserver 0.0.0.0:8000 "
ports:
\- 8000:8000
restart: always

the docker file

FROM  python:3.10
EXPOSE 8000
WORKDIR /
COPY happy_traveller .
COPY requirements.txt .
RUN pip install -r requirements.txt
COPY . .

and the app structure

|_App_Folder
      |_happy_traveller
            |_API
            |_paycache
            |_core
            |_settings
            |_templates
            |_folder
            |_folder
            |_folder
            |_manage.py
       |_dockerfile
       |_docker-compose.yml
       |_requirements.txt
       |_readmme.md
       |_get-pip.py

We would really apreciate the help. thank you for your time

Upvotes: 1

Views: 565

Answers (1)

dreambold
dreambold

Reputation: 3050

As you copied the source folder(happy_traveller) in your docker file, you don't need to run the cd command again, so the docker-compose file would look like this:

version: "2.12.2"

services:
  web:
    tty: true
    build:
      dockerfile: Dockerfile
      context: .
    command: bash -c "python manage.py runserver 0.0.0.0:8000 "
    ports:
      - 8000:8000
    restart: always

Upvotes: 1

Related Questions