2016-11-25 3 views
1

나는 ECS Getting Started tutorial을 따라 갔으나 ECS 에이전트가 컨테이너를 시작하지 못했습니다. 같은 인스턴스에서 수동으로 이미지를 시작하면 시작됩니다.ECS 에이전트 시작 도커 컨테이너가 완료되지 않습니다. 수동 시작 성공

이미지는 /에서 단일 끝 점이있는 Spring Boot 웹 응용 프로그램이며 "Hello world !!"라는 문자열을 반환합니다. 컨테이너는 로컬에서 잘 실행되며 내가 만든 CentOS EC2 인스턴스에서도 제대로 실행됩니다. 엔드 포인트는 CentOS EC2 인스턴스에서 도커 이미지를 실행할 때 공개적으로 사용할 수 있습니다.

ECS 인스턴스에는 마법사에서 만든 보안 그룹이 있으며 포트 80이 열려 있습니다. SSH 액세스를 위해 포트 22를 추가했습니다.

ECS 인스턴스에서 SSH를 실행하여 컨테이너에 대한 Docker 로그를 볼 때 엔트리 포인트 실행 중에 걸려있는 것처럼 보입니다. 여기

은 부두 노동자에 매달려 예를 들어 로그입니다 : 내 컨테이너 이미지에서 응용 프로그램 오류 것 같아 처음에는

[[email protected] ~]$ docker logs --tail 100 107d4cf04dd8 

    . ____   _   __ _ _ 
/\\/___'_ __ _ _(_)_ __ __ _ \ \ \ \ 
(()\___ | '_ | '_| | '_ \/ _` | \ \ \ \ 
\\/ ___)| |_)| | | | | || (_| | )))) 
    ' |____| .__|_| |_|_| |_\__, |//// 
=========|_|==============|___/=/_/_/_/ 
:: Spring Boot ::  (v1.4.2.RELEASE) 

2016-11-25 17:36:22.505 INFO 1 --- [   main] ecstest.Application      : Starting Application on 107d4cf04dd8 with PID 1 (/ecstest-1.0-SNAPSHOT.jar started by root in /) 
2016-11-25 17:36:22.546 INFO 1 --- [   main] ecstest.Application      : No active profile set, falling back to default profiles: default 
2016-11-25 17:36:23.059 INFO 1 --- [   main] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot[email protected]6d21714c: startup date [Fri Nov 25 17:36:23 UTC 2016]; root of context hierarchy 
2016-11-25 17:36:30.972 INFO 1 --- [   main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat initialized with port(s): 8080 (http) 
2016-11-25 17:36:31.014 INFO 1 --- [   main] o.apache.catalina.core.StandardService : Starting service Tomcat 
2016-11-25 17:36:31.016 INFO 1 --- [   main] org.apache.catalina.core.StandardEngine : Starting Servlet Engine: Apache Tomcat/8.5.6 
2016-11-25 17:36:31.464 INFO 1 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/]  : Initializing Spring embedded WebApplicationContext 
2016-11-25 17:36:31.464 INFO 1 --- [ost-startStop-1] o.s.web.context.ContextLoader   : Root WebApplicationContext: initialization completed in 8458 ms 

,하지만 난 고정 표시기 프로세스를 중지하고, 수동으로 출력을 동일한 이미지를 실행할 때 기대 한대로 인스턴스 외부에서 내 끝점에 연결할 수 있습니다.

[[email protected] ~]$ docker stop -t 1 4d2401d7db93 && docker run -p 80:8080 -d ############.dkr.ecr.us-west-2.amazonaws.com/ecstest 
4d2401d7db93 
db8cffa89995401d9314d7d70e954f09c7fde972a5e6a423615827d8c47b9d10 
[[email protected] ~]$ docker ps 
CONTAINER ID  IMAGE             COMMAND     CREATED    STATUS    PORTS     NAMES 
db8cffa89995  ############.dkr.ecr.us-west-2.amazonaws.com/ecstest "java -jar ecstest-1." 10 seconds ago  Up 9 seconds  0.0.0.0:80->8080/tcp small_gates 
85bd18480c99  amazon/amazon-ecs-agent:latest       "/agent"     11 minutes ago  Up 11 minutes        ecs-agent 
[[email protected] ~]$ docker logs --tail 1000 db8cffa89995 

    . ____   _   __ _ _ 
/\\/___'_ __ _ _(_)_ __ __ _ \ \ \ \ 
(()\___ | '_ | '_| | '_ \/ _` | \ \ \ \ 
\\/ ___)| |_)| | | | | || (_| | )))) 
    ' |____| .__|_| |_|_| |_\__, |//// 
=========|_|==============|___/=/_/_/_/ 
:: Spring Boot ::  (v1.4.2.RELEASE) 

2016-11-25 18:06:57.960 INFO 1 --- [   main] ecstest.Application      : Starting Application on db8cffa89995 with PID 1 (/ecstest-1.0-SNAPSHOT.jar started by root in /) 
2016-11-25 18:06:58.004 INFO 1 --- [   main] ecstest.Application      : No active profile set, falling back to default profiles: default 
2016-11-25 18:06:58.578 INFO 1 --- [   main] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot[email protected]6d21714c: startup date [Fri Nov 25 18:06:58 UTC 2016]; root of context hierarchy 
2016-11-25 18:07:05.784 INFO 1 --- [   main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat initialized with port(s): 8080 (http) 
2016-11-25 18:07:05.866 INFO 1 --- [   main] o.apache.catalina.core.StandardService : Starting service Tomcat 
2016-11-25 18:07:05.876 INFO 1 --- [   main] org.apache.catalina.core.StandardEngine : Starting Servlet Engine: Apache Tomcat/8.5.6 
2016-11-25 18:07:06.283 INFO 1 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/]  : Initializing Spring embedded WebApplicationContext 
2016-11-25 18:07:06.283 INFO 1 --- [ost-startStop-1] o.s.web.context.ContextLoader   : Root WebApplicationContext: initialization completed in 7753 ms 
2016-11-25 18:07:07.026 INFO 1 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean : Mapping servlet: 'dispatcherServlet' to [/] 
2016-11-25 18:07:07.031 INFO 1 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'characterEncodingFilter' to: [/*] 
2016-11-25 18:07:07.031 INFO 1 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'hiddenHttpMethodFilter' to: [/*] 
2016-11-25 18:07:07.032 INFO 1 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'httpPutFormContentFilter' to: [/*] 
2016-11-25 18:07:07.033 INFO 1 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'requestContextFilter' to: [/*] 
2016-11-25 18:07:08.432 INFO 1 --- [   main] s.w.s.m.m.a.RequestMappingHandlerAdapter : Looking for @ControllerAdvice: org.springframework.boot[email protected]6d21714c: startup date [Fri Nov 25 18:06:58 UTC 2016]; root of context hierarchy 
2016-11-25 18:07:08.786 INFO 1 --- [   main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[],methods=[GET]}" onto public java.lang.String ecstest.Application.get() 
2016-11-25 18:07:08.800 INFO 1 --- [   main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error],produces=[text/html]}" onto public org.springframework.web.servlet.ModelAndView org.springframework.boot.autoconfigure.web.BasicErrorController.errorHtml(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse) 
2016-11-25 18:07:08.801 INFO 1 --- [   main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error]}" onto public org.springframework.http.ResponseEntity<java.util.Map<java.lang.String, java.lang.Object>> org.springframework.boot.autoconfigure.web.BasicErrorController.error(javax.servlet.http.HttpServletRequest) 
2016-11-25 18:07:09.036 INFO 1 --- [   main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/webjars/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler] 
2016-11-25 18:07:09.036 INFO 1 --- [   main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler] 
2016-11-25 18:07:09.204 INFO 1 --- [   main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/**/favicon.ico] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler] 
2016-11-25 18:07:09.893 INFO 1 --- [   main] o.s.j.e.a.AnnotationMBeanExporter  : Registering beans for JMX exposure on startup 
2016-11-25 18:07:10.201 INFO 1 --- [   main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat started on port(s): 8080 (http) 
2016-11-25 18:07:10.216 INFO 1 --- [   main] ecstest.Application      : Started Application in 14.385 seconds (JVM running for 16.522) 

ECS 에이전트가 내 응용 프로그램을 시작하지 못하는 이유는 무엇입니까?

작업 정의 JSON

{ 
    "attributes": null, 
    "requiresAttributes": [ 
    { 
     "value": null, 
     "name": "com.amazonaws.ecs.capability.ecr-auth", 
     "targetId": null, 
     "targetType": null 
    } 
    ], 
    "taskDefinitionArn": "arn:aws:ecs:us-west-2:############:task-definition/DcTaskDefinition:4", 
    "networkMode": "bridge", 
    "status": "ACTIVE", 
    "revision": 4, 
    "taskRoleArn": null, 
    "containerDefinitions": [ 
    { 
     "volumesFrom": [], 
     "memory": 128, 
     "extraHosts": null, 
     "dnsServers": null, 
     "disableNetworking": null, 
     "dnsSearchDomains": null, 
     "portMappings": [ 
     { 
      "hostPort": 80, 
      "containerPort": 8080, 
      "protocol": "tcp" 
     } 
     ], 
     "hostname": null, 
     "essential": true, 
     "entryPoint": null, 
     "mountPoints": [], 
     "name": "DcContainer", 
     "ulimits": null, 
     "dockerSecurityOptions": null, 
     "environment": [], 
     "links": null, 
     "workingDirectory": null, 
     "readonlyRootFilesystem": null, 
     "image": "############.dkr.ecr.us-west-2.amazonaws.com/ecstest:latest", 
     "command": null, 
     "user": null, 
     "dockerLabels": null, 
     "logConfiguration": null, 
     "cpu": 0, 
     "privileged": null, 
     "memoryReservation": null 
    } 
    ], 
    "placementConstraints": [], 
    "volumes": [], 
    "family": "DcTaskDefinition" 
} 
+2

ECS가 실행될 때 컨테이너가 시작되는 방법과 수동으로 컨테이너를 시작할 때 시작되는 방식이 다를 수 있습니다. ** ECS Task Definition ** JSON을 게시 할 수 있습니까? –

+0

안녕하세요 @ JohananLieberman 작업 정의를 추가했습니다. 감사합니다 – BenR

답변

2

JSON 컨테이너에 하드 메모리 제한을 부과 작업 정의의 memory 키를 누릅니다. 컨테이너가 제한을 초과하려고하면 Docker 데몬이이를 제한하려고합니다. 이것이 컨테이너가 "멈추는"원인이 될지 모르지만 ECS가 실행될 때 컨테이너가 실행되는 방식과 명령 줄에서 실행되는 방식 사이에 유일한 차이점이 있습니다. 그래서 memory 값을 적어도 300으로 설정하거나 메모리 제한을 적용하는 대신 memoryReservation 키를 사용하려고합니다.

하드 및 소프트 메모리 한계 간의 차이점에 대한 자세한 내용은 official ECS documentation에서 확인할 수 있습니다.

+1

그 트릭을 한 것으로 보인다. 1024로 메모리를두면 응용 프로그램이 시작되었습니다. @ JohananLieberman에게 감사합니다! – BenR