代码之家  ›  专栏  ›  技术社区  ›  Etherlind

ECR任务定义:容器链接不应该有循环?

  •  1
  • Etherlind  · 技术社区  · 7 年前

    我正在使用AWS-CLI注册ECR任务定义。我的任务定义如下:

    {
    "family": "",
    "taskRoleArn": "",
    "executionRoleArn": "",
    "networkMode": "none",
    "containerDefinitions": [
        {
            "name": "",
            "image": "",
            "cpu": 0,
            "memory": 0,
            "memoryReservation": 0,
            "links": [
                ""
            ],
            "portMappings": [
                {
                    "hostPort": 80, 
                    "protocol": "tcp", 
                    "containerPort": 80
                }
            ],
            "essential": true,
            "entryPoint": [
                ""
            ],
            "command": [
                ""
            ],
            "environment": [
                {
                    "name": "",
                    "value": ""
                }
            ],
            "mountPoints": [
                {
                    "sourceVolume": "",
                    "containerPath": "",
                    "readOnly": true
                }
            ],
            "volumesFrom": [
                {
                    "sourceContainer": "",
                    "readOnly": true
                }
            ],
            "linuxParameters": {
                "capabilities": {
                    "add": [
                        ""
                    ],
                    "drop": [
                        ""
                    ]
                },
                "devices": [
                    {
                        "hostPath": "",
                        "containerPath": "",
                        "permissions": [
                            "mknod"
                        ]
                    }
                ],
                "initProcessEnabled": true
            },
            "hostname": "",
            "user": "",
            "workingDirectory": "",
            "disableNetworking": true,
            "privileged": true,
            "readonlyRootFilesystem": true,
            "dnsServers": [
                ""
            ],
            "dnsSearchDomains": [
                ""
            ],
            "extraHosts": [
                {
                    "hostname": "",
                    "ipAddress": ""
                }
            ],
            "dockerSecurityOptions": [
                ""
            ],
            "dockerLabels": {
                "KeyName": ""
            },
            "ulimits": [
                {
                    "name": "fsize",
                    "softLimit": 0,
                    "hardLimit": 0
                }
            ],
            "logConfiguration": {
                "logDriver": "syslog",
                "options": {
                    "KeyName": ""
                }
            }
        }
    ],
    "volumes": [
        {
            "name": "",
            "host": {
                "sourcePath": ""
            }
        }
    ],
    "placementConstraints": [
        {
            "type": "memberOf",
            "expression": ""
        }
    ],
    "requiresCompatibilities": [
        "EC2"
    ],
    "cpu": "10",
    "memory": "600"
    

    } ,基本上与自动生成的骨架相同:

     aws ecs register-task-definition --generate-cli-skeleton
    

    但在使用命令时

    aws ecs register-task-definition --family taskDef --cli-input-json taskDef-v1.json --region us-east-2
    

    我明白了: 调用RegisterTaskDefinition操作时出错(ClientException):容器链接不应具有循环

    我做错了什么?

    1 回复  |  直到 7 年前
        1
  •  1
  •   Rik Turnbull    7 年前

    导致该特定错误的原因是您定义了空链接:

    "links": [
      ""
    ]
    

    CLI框架是一个需要编辑的模板,它有许多不需要的字段的空值。最小任务定义模板类似于:

    {
      "containerDefinitions": [
        {
          "name": "my-task-name",
          "image": "my-registry/my-image",
          "memoryReservation": 256,
          "cpu": 256
        }
      ]
    }