错误:在Elastic Beanstalk上部署docker / django应用程序时出现“ No ecs任务定义”

时间:2018-11-19 21:31:51

标签: django amazon-web-services docker amazon-elastic-beanstalk

在AWS Elastic Beanstalk上使用docker / django部署应用程序时遇到问题。 我已经将代码上传到云中,但是,仍然出现错误“在环境中找不到ecs任务定义(或空定义文件)”。

我已经将我的Dockerrun.aws.json文件创建为休假:

{
  "AWSEBDockerrunVersion": 2,
  "volumes": [
    {
      "name": "djangoapp",
      "host": {
        "sourcePath": "/opt/services/djangoapp"
      }
    },
    {
      "name": "nginx",
      "host": {
        "sourcePath": "/etc/nginx/conf.d"
      }
    }  
  ],
  "containerDefinitions": [
    {
      "name": "nginx",
      "image": "nginx:1.13",
      "essential": true,
      "memory": 200,
      "cpu": 1,
      "portMappings": [
        {
          "hostPort": 80,
          "containerPort": 80,
          "protocol": "tcp"
        }
      ],
      "links": [
        "djangoapp"
      ],
      "mountPoints": [
        {
          "sourceVolume": "djangoapp",
          "containerPath": "/opt/services/djangoapp",
          "readOnly": true
        },
        {
          "sourceVolume": "nginx",
          "containerPath": "/etc/nginx/conf.d",
          "readOnly": true
        },
        {
          "sourceVolume": "awseb-logs-nginx-proxy",
          "containerPath": "/var/log/nginx"
        }
      ]
    },
    {
      "name": "djangoapp",
      "image": "nginx:1.13",
      "essential": true,
      "memory": 128,
      "mountPoints": [
        {
          "sourceVolume": "djangoapp",
          "containerPath": "/opt/services/djangoapp",
          "readOnly": true
        }
      ]
    }
  ]
}

我已在AWS页面(https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/create_deploy_docker_v2config.html#create_deploy_docker_v2config_dockerrun)上阅读了该教程,但仍无法正常工作。

要构建此文件,我尝试对docker-compose文件进行反向工程。休假:

version: '3'

services:

  # database containers, one for each db
  database1:
    image: postgres:10
    volumes:
      - database1_volume:/var/lib/postgresql/data
    env_file:
      - config/db/database1_env
    networks:
      - database1_network

  # web container, with django + gunicorn
  djangoapp:
    build: .
    restart: on-failure
    volumes:
      - .:/opt/services/djangoapp/
      - static:/opt/services/djangoapp/static
    networks:
      - database1_network
      - nginx_network
    depends_on:
      - database1
    expose:
      - "8000"

  # reverse proxy container (nginx)
  nginx:
    image: nginx:1.13
    ports:
      - 8000:80
    volumes:
      - ./config/nginx/conf.d:/etc/nginx/conf.d
      - static:/opt/services/djangoapp/static
    networks:
      - nginx_network
    depends_on:
      - djangoapp

networks:
  database1_network:
    driver: bridge
  nginx_network:
    driver: bridge

volumes:
  database1_volume:
  static:
  media:

感谢您的帮助。

谢谢

更新:

我发现了与此有关的错误。创建代码包时,我包括了项目文件夹。阅读This article后,我发现了自己的错误。但是,访问AWS页面顶部的URL后,我仍然无法访问我的应用程序。该符号为绿色,并且在提示符下未显示任何错误。访问URL时,它仅返回未找到的URL。 如果有人遇到此问题,请看一眼。

0 个答案:

没有答案