amazon-web-services - ECS任务不断抛出错误 "DockerClientConfigError: unable to get BridgeIP for task in bridge mode"

标签 amazon-web-services docker aws-cloudformation amazon-ecs fluentd

ECS Console Error 我正在使用 AWS ECS 部署两项服务。第一个服务是我的前端服务(副本),第二个服务是 Fluentbit 日志驱动程序(DAEMON)。前端服务从来没有出现过问题,并且像它应该的那样出现,通过了所有运行状况检查等。但是,当我在同一服务中部署另一个任务定义,或者部署一个单独的服务及其自己的任务定义时,我得到错误“状态原因 DockerClientConfigError:无法在桥接模式下获取任务的 BridgeIP”

这里不存在 NAT 网关不存在或任何其他问题的问题。我可以登录到 EC2 主机并进行更新、提取包等。这是我的 cloudformation 模板的片段,它显示了我如何正在设置服务。

service:
    Type: AWS::ECS::Service
    DependsOn: 
      - ALBListener
      - ECSAutoScalingGroup
    Properties:
      Cluster: !Ref 'ECSCluster'
      LaunchType: EC2
      ServiceName: vrs-client-test-service
      DeploymentController: 
        Type: ECS
      DesiredCount: 4
      PlacementStrategies:
        - Field: instanceId
          Type: spread
      LoadBalancers:
      - ContainerName: vrs-client-test
        ContainerPort: 443
        TargetGroupArn: arn:aws:elasticloadbalancing:us-east-1:<acctnumber>:targetgroup/vrs-client-test-container/e0fee39950d680ec
      TaskDefinition: !Ref 'taskdefinition'
      ServiceRegistries:
        - RegistryArn: !GetAtt DiscoveryService.Arn
          ContainerName: vrs-client-test
          ContainerPort: 443
taskdefinition:
    Type: AWS::ECS::TaskDefinition
    Properties:
      Family: !Join ['', [!Ref 'AWS::StackName', -vrs-client-test]]
      ContainerDefinitions:
      - Name: vrs-client-test
        Essential: true
        Image: <acctid>.dkr.ecr.us-east-1.amazonaws.com/vrs-client:sha.df4f418f
        Cpu: 256
        Memory: 512
        PortMappings:
          - ContainerPort: 443
            HostPort: 0
fluentservice:
    Type: AWS::ECS::Service
    Properties:
      Cluster: !Ref 'ECSCluster'
      LaunchType: EC2
      ServiceName: vrs-client-fluentbit
      DeploymentController:
        Type: ECS
      SchedulingStrategy: DAEMON
      TaskDefinition: !Ref 'taskdefinitionfluent'
taskdefinitionfluent:
    Type: AWS::ECS::TaskDefinition
    Properties:
      Family: !Join ['', [!Ref 'AWS::StackName', -vrs-client-test-fluent]]
      ContainerDefinitions:
      - Name: log_router
        FirelensConfiguration:
            Type: fluentbit
            Options:
              enable-ecs-log-metadata: true
        Essential: true
        Image: 906394416424.dkr.ecr.us-east-1.amazonaws.com/aws-for-fluent-bit:latest
        Memory: 100
        LogConfiguration:
          LogDriver: awsfirelens
          Options:
           Port: "443"
            tls: 'on'
            tls.verify: 'off'
            Format: "json_lines"

最佳答案

我在任务定义中看到了同样的错误。它有我的应用程序容器和一个 Fluent-bit 容器。 Fluent-bit 容器被配置为从应用程序容器安装卷。因此 ECS 尝试首先启动应用程序容器。

有人向我指出了这个 AWS 文档:https://docs.aws.amazon.com/AmazonECS/latest/userguide/using_firelens.html

For tasks that use the bridge network mode, the container with the FireLens configuration must start before any application containers that rely on it start. To control the start order of your containers, use dependency conditions in your task definition. For more information, see Container dependency.

Note: If you use dependency condition parameters in container definitions with a FireLens configuration, ensure that each container has a START or HEALTHY condition requirement.

所以要实现这个,

  1. 我通过让应用容器从 Fluent-bit 容器挂载卷来反转依赖关系。
  2. 此外,我还使用依赖项配置来强制 Fluent-bit 容器在 App 容器之前启动。

现在任务定义正在完美运行!

此外,我之前的设置(使用 Fluent-bit 容器,具体取决于应用程序容器)在网络模式 = awsvpc 下运行良好

当我将网络模式切换为桥接时,我开始收到无法获取 BridgeIP 错误。

关于amazon-web-services - ECS任务不断抛出错误 "DockerClientConfigError: unable to get BridgeIP for task in bridge mode",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62305211/

相关文章:

json - 使用 HTTPS JSON 正文将消息发送到 SQS

amazon-web-services - 用于在 AWS EB 容器服务上部署的 Gitlab 注册表凭证

java - 如何从 S3 到 S3 并行处理

docker - 带有 Docker Provider 的 Vagrant 需要 RSync 密码

docker - linuxkit getty 陷入困境

mysqli - 云信息 : Why does RDS instance creates default security group when i am already creating one while initating RDS?

database - Dynamo DB 中的多个属性作为哈希键

amazon-web-services - 如何为 AWS ECS 中运行的 Docker 容器配置 "ulimits"?

amazon-web-services - AWS Cloudformation 模板 : Which Section?

docker - 在 Jenkinsfile 中使用 Dockerfile 创建的 docker 容器内运行命令