Home > Mobile >  Docker container not running - Docker-compose
Docker container not running - Docker-compose

Time:10-16

I am trying to run a django-react app in docker containers and trying to deploy it on digital ocean.

Here is my docker-compose script

version: "3.9"

services:
  web:
    image: "${WEB_IMAGE}"
    container_name: website
    command: gunicorn server.wsgi:application --bind 0.0.0.0:8000
    volumes:
      - static_volume:/usr/src/app/staticfiles
      - media_volume:/usr/src/app/mediafiles
    ports:
      - 8000:8000
    env_file: .env

  nginx:
    image: "${NGINX_IMAGE}"
    container_name: nginx
    volumes:
      - static_volume:/usr/src/app/staticfiles
      - media_volume:/usr/src/app/mediafiles
    ports:
      - 80:80
    depends_on:
      - web

  tensorflow-servings:
    image: "${TENSORFLOW_IMAGE}"
    container_name: tensorflow_serving
    ports:
      - 8501:8501
    depends_on:
      - web

volumes:
  static_volume:
  media_volume:

Here you see nginx and web are listed, but not web. I get 502 Bad Gateway - nginx/1.21.3 error

enter image description here

Update:

When I insert the wrong IP in DJANGO_ALLOWED_HOSTS=localhost 127.0.0.1 in the settings.py, the docker container of the website appears but then I get server error 500. When I insert the correct IP address of the droplet I get 502 Bad Gateway - nginx/1.21.3 error`, and the container of the website does not appear on the droplet anymore.

CodePudding user response:

On the droplet I did

docker ps -a and there it appeared!

33 minutes ago Exited (3) 33 minutes ago

So I followed it with

docker logs <container name>

And the error was in the ALLOWED_HOSTS

  • Related