amazon-web-services - CannotPullContainerError:启动 ECS 任务时出现上下文取消错误
问题描述
我正在使用 Fargate 启动 ECS 任务,并且容器在 PENDING 几分钟后最终处于 STOPPED 状态。状态给出以下错误消息:
CannotPullContainerError: context canceled
我正在使用 PrivateLink 允许 ECS 主机与 ECR 注册表对话,而无需通过公共 Internet,这就是它的配置方式(无服务器语法增强 CloudFormation):
Properties:
PrivateDnsEnabled: true
ServiceName: com.amazonaws.ap-southeast-2.ecr.dkr
SubnetIds:
- { Ref: frontendSubnet1 }
- { Ref: frontendSubnet2 }
VpcEndpointType: Interface
VpcId: { Ref: frontendVpc }
关于导致错误的任何想法?
解决方案
您是否还添加了 S3 端点?这是我的模板的一个工作片段,我能够通过 aws 支持解决这个问题:
EcrDkrEndpoint:
Type: 'AWS::EC2::VPCEndpoint'
Properties:
PrivateDnsEnabled: true
SecurityGroupIds: [!Ref 'FargateContainerSecurityGroup']
ServiceName: !Sub 'com.amazonaws.${AWS::Region}.ecr.dkr'
SubnetIds: [!Ref 'PrivateSubnetOne', !Ref 'PrivateSubnetTwo']
VpcEndpointType: Interface
VpcId: !Ref 'VPC'
对于 S3,您需要知道路由表是必要的 - 通常您希望使用与 Internet 网关相同的路由表,其中包含路由 0.0.0.0/0
S3Endpoint:
Type: 'AWS::EC2::VPCEndpoint'
Properties:
ServiceName: !Sub 'com.amazonaws.${AWS::Region}.s3'
VpcEndpointType: Gateway
VpcId: !Ref 'VPC'
RouteTableIds: [!Ref 'PrivateRouteTable']
如果没有 cloudwatch 的端点,您将再次失败,这也是必要的:
CloudWatchEndpoint:
Type: 'AWS::EC2::VPCEndpoint'
Properties:
PrivateDnsEnabled: true
SecurityGroupIds: [!Ref 'FargateContainerSecurityGroup']
ServiceName: !Sub 'com.amazonaws.${AWS::Region}.logs'
SubnetIds: [!Ref 'PrivateSubnetOne', !Ref 'PrivateSubnetTwo']
VpcEndpointType: Interface
VpcId: !Ref 'VPC'
编辑:私有路由表:
PrivateRoute:
Type: AWS::EC2::Route
DependsOn: InternetGatewayAttachement
Properties:
RouteTableId: !Ref 'PublicRouteTable'
DestinationCidrBlock: '0.0.0.0/0'
GatewayId: !Ref 'InternetGateway'
推荐阅读
- ios - iOS优酷用密码播放视频失败
- nginx - Nginx:如何使用 ngrok 映射内部 IP 地址和代理而不重定向
- postgresql - 在 PostgreSQL 的物化视图上使用的最佳索引类型是什么
- html - Bootstrap 列未出现在较小的屏幕上
- javascript - 如何将字符串转换为 React 元素 - ReactJs/Javascript
- oracle-bi - Oracle BI — 如何创建自定义图表?
- c++ - 将 QtConcurrent 用于 QImage::fill 时未解决的重载函数类型
- python - Validation_data 和 Validation_split
- wordpress - 来自 2 个自定义字段的自定义值的总和
- android - 转到另一个 RecyclerView 新 Activity 时,多个 RecyclerView 布局显示 IndexOutOfBoundsException