Yêu cầu thg 12 27, 2021 1:19 CH 159 0 0
  • 159 0 0
0

Config ECS chỉ được 1 container

Chia sẻ
  • 159 0 0

Mọi người giúp mình với. Mình đang setup 1 cluster chứa 2 container nginx và rails app. Dưới đây là taskdef.json của mình

{
  "ipcMode": null,
  "executionRoleArn": "arn:aws:iam::xxxxxxxxxxxxxx:role/ecsTaskExecutionRole",
  "containerDefinitions": [
    {
      "dnsSearchDomains": null,
      "environmentFiles": null,
      "logConfiguration": {
        "logDriver": "awslogs",
        "secretOptions": null,
        "options": {
          "awslogs-group": "/ecs/gryqhon-lyrics-rails-site",
          "awslogs-region": "ap-northeast-1",
          "awslogs-stream-prefix": "ecs"
        }
      },
      "entryPoint": null,
      "portMappings": [
        {
          "hostPort": 0,
          "protocol": "tcp",
          "containerPort": 8080
        }
      ],
      "command": [
        "bundle",
        "exec",
        "puma",
        "-C",
        "config/docker_puma.rb",
        "-p",
        "8080"
      ],
      "linuxParameters": null,
      "cpu": 0,
      "environment": [
        {
          "name": "MYSQL_DB",
          "value": "lyrics-site-1"
        },
        {
          "name": "MYSQL_HOST",
          "value": "lyrics-site-1.cil753khjwcg.ap-northeast-1.rds.amazonaws.com"
        },
        {
          "name": "MYSQL_PASSWORD",
          "value": "0ebHetteFp"
        },
        {
          "name": "MYSQL_USER_NAME",
          "value": "gryqhon"
        },
        {
          "name": "RAILS_ENV",
          "value": "staging"
        },
        {
          "name": "RAILS_LOG_TO_STDOUT",
          "value": "ENABLED"
        },
        {
          "name": "RAILS_MASTER_KEY",
          "value": "aaaaaaaaaaaaaaaaaaaaaaaa"
        }
      ],
      "resourceRequirements": null,
      "ulimits": null,
      "dnsServers": null,
      "mountPoints": [],
      "workingDirectory": null,
      "secrets": null,
      "dockerSecurityOptions": null,
      "memory": null,
      "memoryReservation": null,
      "volumesFrom": [],
      "stopTimeout": null,
      "image": "xxxxxxxxxxxxxx.dkr.ecr.region.amazonaws.com/lyrics-site-rails_app:latest",
      "startTimeout": null,
      "firelensConfiguration": null,
      "dependsOn": null,
      "disableNetworking": null,
      "interactive": null,
      "healthCheck": null,
      "essential": true,
      "links": null,
      "hostname": null,
      "extraHosts": null,
      "pseudoTerminal": null,
      "user": null,
      "readonlyRootFilesystem": null,
      "dockerLabels": null,
      "systemControls": null,
      "privileged": null,
      "name": "lyrics-site-rails-app"
    },
    {
      "dnsSearchDomains": null,
      "environmentFiles": null,
      "logConfiguration": null,
      "entryPoint": null,
      "portMappings": [
        {
          "hostPort": 80,
          "protocol": "tcp",
          "containerPort": 80
        }
      ],
      "command": null,
      "linuxParameters": null,
      "cpu": 0,
      "environment": [],
      "resourceRequirements": null,
      "ulimits": null,
      "dnsServers": null,
      "mountPoints": [],
      "workingDirectory": null,
      "secrets": null,
      "dockerSecurityOptions": null,
      "memory": null,
      "memoryReservation": null,
      "volumesFrom": [],
      "stopTimeout": null,
      "image": "xxxxxxxxxxxxxx.dkr.ecr.region.amazonaws.com/lyrics-site-rails_web:latest",
      "startTimeout": null,
      "firelensConfiguration": null,
      "dependsOn": [
        {
          "containerName": "lyrics-site-rails-app",
          "condition": "START"
        }
      ],
      "disableNetworking": null,
      "interactive": null,
      "healthCheck": null,
      "essential": true,
      "links": [
        "lyrics-site-rails-app"
      ],
      "hostname": null,
      "extraHosts": null,
      "pseudoTerminal": null,
      "user": null,
      "readonlyRootFilesystem": null,
      "dockerLabels": null,
      "systemControls": null,
      "privileged": null,
      "name": "nginx"
    }
  ],
  "placementConstraints": [],
  "memory": "512",
  "taskRoleArn": null,
  "compatibilities": [
    "EXTERNAL",
    "EC2"
  ],
  "taskDefinitionArn": "arn:aws:ecs:ap-northeast-1:xxxxxxxxxxxxxx:task-definition/gryqhon-lyrics-rails-site:2",
  "family": "gryqhon-lyrics-rails-site",
  "requiresAttributes": [
    {
      "targetId": null,
      "targetType": null,
      "value": null,
      "name": "com.amazonaws.ecs.capability.logging-driver.awslogs"
    },
    {
      "targetId": null,
      "targetType": null,
      "value": null,
      "name": "ecs.capability.execution-role-awslogs"
    },
    {
      "targetId": null,
      "targetType": null,
      "value": null,
      "name": "com.amazonaws.ecs.capability.ecr-auth"
    },
    {
      "targetId": null,
      "targetType": null,
      "value": null,
      "name": "com.amazonaws.ecs.capability.docker-remote-api.1.19"
    },
    {
      "targetId": null,
      "targetType": null,
      "value": null,
      "name": "ecs.capability.container-ordering"
    },
    {
      "targetId": null,
      "targetType": null,
      "value": null,
      "name": "ecs.capability.execution-role-ecr-pull"
    }
  ],
  "pidMode": null,
  "requiresCompatibilities": [
    "EC2"
  ],
  "networkMode": "bridge",
  "runtimePlatform": null,
  "cpu": "512",
  "revision": 2,
  "status": "ACTIVE",
  "inferenceAccelerators": null,
  "proxyConfiguration": null,
  "volumes": []
}

Tuy nhiên khi active, mình đang chỉ nhận được có 1 container. Mình đang bị sai ở đâu mong mọi người giúp đỡ

Rails key và aws mình không dùng key thật trong câu hỏi này

Viblo
Hãy đăng ký một tài khoản Viblo để nhận được nhiều bài viết thú vị hơn.
Đăng kí