Amazon ECS에서 Docker 대몬의 자세한 출력 구성 - Amazon Elastic Container Service

Amazon ECS에서 Docker 대몬의 자세한 출력 구성

Docker 컨테이너나 이미지에 문제가 있는 경우, Docker 대몬에서 디버그 모드를 켤 수 있습니다. 디버깅을 사용하면 대몬에서 더 자세한 출력이 제공됩니다. 이를 사용하여 Amazon ECR과 같은 컨테이너 레지스트리에서 전송된 오류 메시지를 검색할 수 있습니다.

중요

이 절차는 Amazon ECS 최적화 Amazon Linux AMI용으로 작성되었습니다. 다른 운영 체제의 경우 Docker 설명서의 Enable debuggingControl and configure Docker with systemd를 참조하세요.

Amazon ECS 최적화 Amazon Linux AMI에서 Docker 대몬 디버그 모드를 사용하려면
  1. 컨테이너 인스턴스에 연결합니다.

  2. 텍스트 편집기로 Docker 옵션 파일을 엽니다(예: vi). Amazon ECS 최적화 Amazon Linux AMI의 경우 Docker 옵션 파일은 /etc/sysconfig/docker에 있습니다.

  3. Docker 옵션 문장을 찾아 문자열 따옴표 안에 -D 옵션을 추가합니다.

    참고

    Docker 옵션 구문이 #로 시작하는 경우, 해당 문자를 제거해 문장의 주석 처리를 해제하고 옵션을 활성화해야 합니다.

    Amazon ECS 최적화 Amazon Linux AMI의 경우 Docker 옵션 문장을 일컬어 OPTIONS라고 합니다. 예:

    # Additional startup options for the Docker daemon, for example: # OPTIONS="--ip-forward=true --iptables=true" # By default we limit the number of open files per container OPTIONS="-D --default-ulimit nofile=1024:4096"
  4. 파일을 저장하고 텍스트 편집기를 종료합니다.

  5. Docker 대몬을 다시 시작합니다.

    sudo service docker restart

    출력값은 다음과 같습니다.

    Stopping docker: [ OK ] Starting docker: . [ OK ]
  6. Amazon ECS 에이전트를 다시 시작합니다.

    sudo service ecs restart

이제 Docker 로그에 더 상세한 출력이 표시됩니다.

time="2015-12-30T21:48:21.907640838Z" level=debug msg="Unexpected response from server: \"{\\\"errors\\\":[{\\\"code\\\":\\\"DENIED\\\",\\\"message\\\":\\\"User: arn:aws:sts::1111:assumed-role/ecrReadOnly/i-abcdefg is not authorized to perform: ecr:InitiateLayerUpload on resource: arn:aws:ecr:us-east-1:1111:repository/nginx_test\\\"}]}\\n\" http.Header{\"Connection\":[]string{\"keep-alive\"}, \"Content-Type\":[]string{\"application/json; charset=utf-8\"}, \"Date\":[]string{\"Wed, 30 Dec 2015 21:48:21 GMT\"}, \"Docker-Distribution-Api-Version\":[]string{\"registry/2.0\"}, \"Content-Length\":[]string{\"235\"}}"