【发布时间】:2019-08-02 20:15:54
【问题描述】:
我正在使用 .NET Core WEBAPI 及以下 Dockerfile
FROM microsoft/dotnet:sdk AS build-env
WORKDIR /app
# Copy csproj and restore as distinct layers
COPY *.csproj ./
RUN dotnet restore
# Copy everything else and build
COPY . ./
RUN dotnet publish -c Release -o out
# Build runtime image
FROM microsoft/dotnet:aspnetcore-runtime
WORKDIR /app
COPY --from=build-env /app/out .
ENTRYPOINT ["dotnet", "DummyService.dll"]
在我的 cloudformation 模板中,ECS 部分是这样的
dummyWebApiEcsTaskDefinition:
Type: AWS::ECS::TaskDefinition
Properties:
Family: !Ref AWS::StackName
TaskRoleArn: !GetAtt dummyWebApiIamRole.Arn
ContainerDefinitions:
- Name: !Ref AWS::StackName
Image: MY IMAGE URL
DnsSearchDomains:
- !Join [".", [{"Fn::ImportValue": !Sub "${accountStackName}-${AWS::Region}-envName"}, "connected", !If [chinaPartition, "TEST", "CORP"], "cloud"]]
LogConfiguration:
LogDriver: splunk
Options:
splunk-token: {"Fn::ImportValue": !Sub "${splunkHECStackName}-${AWS::Region}-SplunkHECToken"}
splunk-url: "http://splunk-forwarder:8088"
splunk-insecureskipverify: True
tag: !Ref AWS::StackName
splunk-format: json
splunk-source: !Ref AWS::StackName
splunk-sourcetype: AWS:ECS
EntryPoint: []
PortMappings:
- ContainerPort: 5000
Command: []
Cpu: 0
Environment:
- Name: BindAddress
Value: http://0.0.0.0:5000
- Name: MinLogLevel
Value: !If [isProduction, "Information", "Debug"]
Ulimits: []
DnsServers: []
MountPoints: []
DockerSecurityOptions: []
Memory: 512
VolumesFrom: []
Essential: true
ExtraHosts: []
ReadonlyRootFilesystem: false
DockerLabels: {}
Privileged: false
dummyEcsService:
Type: AWS::ECS::Service
DependsOn:
- dummyWebApiIamRole
- dummyInternalAlb
- dummyAlbTargetGroup
Properties:
Cluster:
Fn::ImportValue: !Sub "cld-core-ecs-${AWS::Region}-ECSCluster"
DeploymentConfiguration:
MaximumPercent: 200
MinimumHealthyPercent: 50
DesiredCount: 2
LoadBalancers:
- ContainerName: !Ref AWS::StackName
ContainerPort: 5000
TargetGroupArn: !Ref dummyAlbTargetGroup
PlacementStrategies:
- Type: spread
Field: attribute:ecs.availability-zone
TaskDefinition: !Ref dummyWebApiEcsTaskDefinition
ServiceName: !Ref AWS::StackName
Role: !Sub "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/aws-service-role/ecs.amazonaws.com/AWSServiceRoleForECS"
部署无法完成,我可以在 ECS 服务事件选项卡中看到此错误
service cld-dummy-test 无法放置任务,因为没有容器实例满足其所有要求。原因:在您的集群中没有找到容器实例。
【问题讨论】:
-
您正在为日志使用 Splunk 驱动程序。你确定你的
/etc/ecs.config有包含ECS_AVAILABLE_LOGGING_DRIVERS=["splunk","awslogs"].的条目吗?。 -
@Imran 谢谢伊姆兰。您的观点不是对这个问题的直接回答,而是针对我在解决这个问题后面临的下一个问题。我将在下面发布答案。
标签: amazon-web-services docker .net-core amazon-ecs