Docker Community Forums

Share and learn in the Docker community.

Docker container not accessible from browser

Hi all,
I am able to access nginx and web services from browser but can’t access django and flower.
For django,no response is there but for flower it shows “waiting for host”.
The respective logs show all containers are running without any error.
I replicated the nginx configuration file from somewhere else and not sure if that is correct.

docker-compose.yml

version: "3"

services:
  nginx:
    image: "nginx:1.15.8-alpine"
    ports:
      - 8080:80
    networks:
      - nra

  django:
    build:
      context: ./backend
      dockerfile: Dockerfile

    #tty: true
    ports:
      - 8000:8000
    env_file: .env 
    links:
      - db
      - redismb
    depends_on:
      - db
    networks:
      - nra
  db:
    image: postgres:11.2-alpine
    ports:
      - 5432:5432
    volumes:
      - ./data/new_db_data_01/:/var/lib/postgresql/data/

    env_file: .env
    networks:
      - nra
  #Redis
  redismb:
    image: redis:2.8.19
    hostname: redis
    ports:
      - "6379:6379"
    networks:
      - nra

  web:
    build:
      context: ./frontend
      dockerfile: Dockerfile
    ports:
      - 6500:4200
    depends_on:
      - django
    networks:
      - nra
  celery:
    build:
      context: ./backend
      dockerfile: Dockerfile
    env_file: .env
    command: celery -A nrn worker -l info --uid nobody --gid nobody
    depends_on:
      - django
      - redismb
    networks:
      - nra

  flower:
    build:
      context: ./backend
      dockerfile: Dockerfile
    ports:
      - 5555:5555
    command: flower -A abc --port=5555
    depends_on:
      - celery
    networks:
      - nra


networks:
  nra:
    driver: bridge

Dockerfile(django)

FROM frolvlad/alpine-miniconda3:python3.7 as base

FROM base as builder
WORKDIR /usr/src/app
COPY ./requirements.txt /usr/src/app/requirements.txt
RUN python -m venv /opt/venv
# Make sure we use the virtualenv:
ENV PATH="/opt/venv/bin:$PATH"
RUN pip install gunicorn


RUN pip install -r requirements.txt


FROM base
RUN apk add nginx bash
COPY --from=builder /usr/src/app /usr/src/app
COPY --from=builder /opt/venv /opt/venv
ENV PATH="/opt/venv/bin:$PATH"

COPY . /usr/src/app/rapid-nrn-backend
WORKDIR /usr/src/app/rapid-nrn-backend

CMD ["/bin/bash", "entrypoint.sh"]
EXPOSE 80
EXPOSE 8000

nginx.conf

worker_processes  1;
events {
  worker_connections  1024;
}
http {
    upstream myapp {
    ip_hash;
    server web:6500;
}
upstream myapp_dj {
    ip_hash;
    server django:8000;
}
server {
    listen 80;
    location / {
        proxy_pass http://myapp/;
        proxy_set_header Upgrade    $http_upgrade;
        proxy_set_header Connection $http_connection;
        proxy_set_header Host       $host;
    }
    location ^~ /admin {
        proxy_pass http://myapp_dj/admin;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Host $host;
        proxy_redirect off;
    }
    location ^~ /django {
        proxy_pass http://myapp_dj/;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Host $host;
        proxy_redirect off;
    }
}
}

These are the port mappings


Any help is highly appreciated.