【问题标题】:Docker container not running - Docker-composeDocker 容器未运行 - Docker-compose
【发布时间】:2021-12-01 17:37:56
【问题描述】:

我正在尝试在 docker 容器中运行 django-react 应用程序并尝试将其部署在数字海洋上。

这是我的 docker-compose 脚本

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:

在这里,您看到列出了 nginx 和 web,但没有列出 web。我收到502 Bad Gateway - nginx/1.21.3 错误

更新:

当我在settings.py 中的DJANGO_ALLOWED_HOSTS=localhost 127.0.0.1 中插入错误的IP 时,会出现网站的docker 容器,但随后我得到server error 500。当我插入正确的水滴IP地址时,我得到502 Bad Gateway - nginx/1.21.3错误`,并且网站的容器不再出现在水滴上。

【问题讨论】:

  • 什么是 ${WEB_IMAGE} ?
  • 嘿@TobiasS.,${WEB_IMAGE}Github workflows 中定义为docker-compose -f docker-compose.ci.yml build。这在本地运行良好。

标签: django docker nginx gunicorn digital-ocean


【解决方案1】:

在我做的水滴上

docker ps -a 它出现了!

33 minutes ago Exited (3) 33 minutes ago

所以我跟着它

docker logs <container name>

错误出现在ALLOWED_HOSTS

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-11-27
    • 2019-05-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多