

기계 번역으로 제공되는 번역입니다. 제공된 번역과 원본 영어의 내용이 상충하는 경우에는 영어 버전이 우선합니다.

# Docker 컨테이너로 AWS IoT Greengrass V2 실행 중인에 컨테이너화된 애플리케이션 배포
<a name="deploy-containerized-applications-on-aws-iot-greengrass-version-2-running-as-a-docker-container"></a>

*Salih Bakir, Giuseppe Di Bella, Gustav Svalander, Amazon Web Services*

## 요약
<a name="deploy-containerized-applications-on-aws-iot-greengrass-version-2-running-as-a-docker-container-summary"></a>

AWS IoT Greengrass Version 2는 Docker 컨테이너로 배포될 때 기본적으로 Docker 애플리케이션 컨테이너 실행을 지원하지 않습니다. 이 패턴은 DinD(DockerDocker-in-Docker) 기능을 활성화 AWS IoT Greengrass V2 하는 최신 버전의를 기반으로 사용자 지정 컨테이너 이미지를 생성하는 방법을 보여줍니다. DinD를 사용하면 AWS IoT Greengrass V2 환경 내에서 컨테이너화된 애플리케이션을 실행할 수 있습니다.

이 패턴을 독립형 솔루션으로 배포하거나 Amazon ECS Anywhere와 같은 컨테이너 오케스트레이션 플랫폼과 통합할 수 있습니다. 두 배포 모델에서는 확장 가능한 컨테이너 기반 배포를 활성화하면서 AWS IoT SiteWise 엣지 처리 기능을 포함한 전체 AWS IoT Greengrass V2 기능을 유지합니다.

## 사전 조건 및 제한 사항
<a name="deploy-containerized-applications-on-aws-iot-greengrass-version-2-running-as-a-docker-container-prereqs"></a>

**사전 조건 **
+ 활성. AWS 계정
+ 일반적인 AWS IoT Greengrass Version 2 사전 조건은 AWS IoT Greengrass Version 2 설명서의 [사전 조건을 참조하세요](https://docs.aws.amazon.com/greengrass/v2/developerguide/getting-started-prerequisites.html).
+ Linux, macOS 또는 Windows에 설치 및 구성된 Docker Engine.
+ Docker Compose(Docker Compose 명령줄 인터페이스(CLI)를 사용하여 Docker 이미지를 실행하는 경우).
+ Linux 운영 체제.
+ 가상화를 지원하는 호스트 서버가 있는 하이퍼바이저입니다.
+ 시스템 요구 사항:
  + RAM 2GB(최소)
  + 사용 가능한 디스크 공간 5GB(최소)
  +  AWS IoT SiteWise Edge의 경우 16GB의 RAM과 50GB의 사용 가능한 디스크 공간이 있는 x86\_64 쿼드 코어 CPU입니다. AWS IoT SiteWise 데이터 처리에 대한 자세한 내용은 AWS IoT SiteWise 설명서의 [데이터 처리 팩 요구 사항을](https://docs.aws.amazon.com/iot-sitewise/latest/userguide/configure-gateway-ggv2.html#w2aac17c19c13b7) 참조하세요.

**제품 버전**
+ AWS IoT Greengrass Version 2 버전 2.5.3 이상
+ Docker-in-Docker 버전 1.0.0 이상
+ Docker Compose 버전 1.22 이상
+ Docker Engine 버전 20.10.12 이상

**제한 사항 **
+ 일부 AWS 서비스 는 전혀 사용할 수 없습니다 AWS 리전. 리전별 가용성은 [리전별AWS 서비스](https://aws.amazon.com/about-aws/global-infrastructure/regional-product-services/)를 참조하세요. 구체적인 엔드포인트는 [서비스 엔드포인트 및 할당량](https://docs.aws.amazon.com/general/latest/gr/aws-service-information.html)을 참조하고 서비스 링크를 선택합니다.

## 아키텍처
<a name="deploy-containerized-applications-on-aws-iot-greengrass-version-2-running-as-a-docker-container-architecture"></a>

**대상 기술 스택**
+ **데이터 소스** - 처리를 위해 데이터를 생성하는 IoT 디바이스, 센서 또는 산업 장비
+ **AWS IoT Greengrass V2** - 엣지 인프라에 배포된 D-in-D 기능이 있는 Docker 컨테이너로 실행
+ **컨테이너화된 애플리케이션** - AWS IoT Greengrass V2 환경 내에서 중첩된 Docker 컨테이너로 실행되는 사용자 지정 애플리케이션
+ **(선택 사항) Amazon ECS Anywhere** – 컨테이너 배포를 관리하는 AWS IoT Greengrass V2 컨테이너 오케스트레이션
+ **기타 AWS 서비스** - 데이터 처리 및 관리를 AWS 서비스 위한 AWS IoT Core AWS IoT SiteWise및 기타

**대상 아키텍처 **

다음 다이어그램은 컨테이너 관리 도구인 Amazon ECS Anywhere를 사용하는 대상 배포 아키텍처의 예를 보여줍니다.

![Amazon ECS Anywhere를 사용하는 배포 아키텍처.](http://docs.aws.amazon.com/ko_kr/prescriptive-guidance/latest/patterns/images/pattern-img/2ecf5354-40e0-4fd9-9798-086719059784/images/5ed2652e-9604-4809-8962-b167e1991658.png)


이 다이어그램은 다음 워크플로를 보여줍니다.

**1: 컨테이너 이미지 스토리지** - Amazon ECR은 엣지 처리에 필요한 AWS IoT Greengrass 컨테이너 이미지와 사용자 지정 애플리케이션 컨테이너를 저장합니다.

**2 **및** 3: 컨테이너 배포** - Amazon ECS Anywhere는 Amazon ECR에서 엣지 로케이션으로 AWS IoT Greengrass 컨테이너 이미지를 배포하여 컨테이너 수명 주기 및 배포 프로세스를 관리합니다.

**4: 구성 요소 배포** - 배포된 AWS IoT Greengrass 코어는 구성에 따라 관련 구성 요소를 자동으로 배포합니다. 구성 요소에는 컨테이너화된 환경 내의 AWS IoT SiteWise 엣지 및 기타 필요한 엣지 처리 구성 요소가 포함됩니다.

**5: 데이터 수집 **- 완전히 구성된 후 엣지 로케이션의 다양한 IoT 데이터 소스에서 원격 측정 및 센서 데이터를 수집하기 AWS IoT Greengrass 시작합니다.

**6: 데이터 처리 및 클라우드 통합** - 컨테이너화된 AWS IoT Greengrass 코어는 배포된 구성 요소(산업 데이터용 AWS IoT SiteWise Edge 포함)를 사용하여 로컬에서 데이터를 처리합니다. 그런 다음 추가 분석 및 저장을 위해 처리된 데이터를 AWS 클라우드 서비스로 전송합니다.

## 도구
<a name="deploy-containerized-applications-on-aws-iot-greengrass-version-2-running-as-a-docker-container-tools"></a>

**AWS 서비스**
+ [Amazon ECS Anywhere](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/launch-type-external.html)는 자체 인프라에서 Amazon ECS 작업 및 서비스를 배포, 사용 및 관리하는 데 도움이 됩니다.
+ [Amazon Elastic Compute Cloud(Amazon EC2)](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/concepts.html)는 AWS 클라우드에서 확장 가능한 컴퓨팅 용량을 제공합니다. 필요한 만큼 가상 서버를 시작하고 빠르게 스케일 업하거나 스케일 다운할 수 있습니다.
+ [Amazon Elastic Container Registry(Amazon ECR)](https://docs.aws.amazon.com/AmazonECR/latest/userguide/what-is-ecr.html)는 안전하고 확장성이 있고 신뢰할 수 있는 관리형 컨테이너 이미지 레지스트리 서비스입니다.
+ [AWS IoT Greengrass](https://docs.aws.amazon.com/greengrass/v2/developerguide/what-is-iot-greengrass.html)는 디바이스에서 IoT 애플리케이션을 구축, 배포 및 관리하는 데 도움이 되는 오픈 소스 사물 인터넷(IoT) 엣지 런타임 및 클라우드 서비스입니다.
+ AWS IoT SiteWise를 사용하면 대규모로 산업 장비 데이터를 수집, 구성 및 분석할 수 있습니다.

**기타 도구**
+ [Docker](https://www.docker.com/)는 운영 체제 수준의 가상화를 사용하여 컨테이너에 소프트웨어를 제공하는 서비스형 플랫폼(PaaS) 제품 세트입니다.
+ [Docker Compose](https://docs.docker.com/compose/)는 멀티컨테이너 애플리케이션을 정의하고 실행하는 도구입니다.
+ [Docker Engine](https://docs.docker.com/engine/)은 애플리케이션을 구축하고 컨테이너화하기 위한 오픈 소스 컨테이너화 기술입니다.

**코드 리포지토리**

이 패턴의 코드는 GitHub [AWS IoT Greengrass v2 Docker-in-Docker](https://github.com/aws-samples/aws-iot-greengrass-docker-in-docker) 리포지토리에서 사용할 수 있습니다.

## 에픽
<a name="deploy-containerized-applications-on-aws-iot-greengrass-version-2-running-as-a-docker-container-epics"></a>

### AWS IoT Greengrass V2 Docker-in-Docker 이미지 빌드
<a name="build-the-gg2-docker-in-docker-image"></a>


| 작업 | 설명 | 필요한 기술 | 
| --- | --- | --- | 
| 를 복제하고 리포지토리로 이동합니다. | 리포지토리를 복제하려면 다음 명령을 사용합니다.<br />`git clone https://github.com/aws-samples/aws-iot-greengrass-docker-in-docker.git`<br />`docker` 디렉터리로 이동하려면 다음 명령을 사용합니다.<br />`cd aws-iot-greengrass-docker-in-docker/docker` | DevOps 엔지니어, AWS DevOps | 
| Docker 이미지를 구축합니다. | 기본(최신) 버전으로 Docker 이미지를 빌드하려면 다음 명령을 실행합니다.<br />`docker build -t x86_64/aws-iot-greengrass:latest .`<br />또는 특정 버전으로 Docker 이미지를 빌드하려면 다음 명령을 실행합니다.<br />`docker build --build-arg GREENGRASS_RELEASE_VERSION=2.12.0 -t x86_64/aws-iot-greengrass:2.12.0 .`<br />빌드를 확인하려면 다음 명령을 실행합니다.<br />`docker images \| grep aws-iot-greengrass`<br />  | AWS DevOps, DevOps 엔지니어, 앱 개발자 | 
| (선택 사항) Amazon ECR로 푸시합니다. | [See the AWS documentation website for more details](http://docs.aws.amazon.com/ko_kr/prescriptive-guidance/latest/patterns/deploy-containerized-applications-on-aws-iot-greengrass-version-2-running-as-a-docker-container.html) | 앱 개발자, AWS DevOps, DevOps 엔지니어 | 

### AWS 자격 증명 구성
<a name="configure-aws-credentials"></a>


| 작업 | 설명 | 필요한 기술 | 
| --- | --- | --- | 
| 인증 방법을 선택합니다. | 다음 옵션 중 하나를 선택하세요.[See the AWS documentation website for more details](http://docs.aws.amazon.com/ko_kr/prescriptive-guidance/latest/patterns/deploy-containerized-applications-on-aws-iot-greengrass-version-2-running-as-a-docker-container.html) | 관리자 | 
| 인증 방법을 구성합니다. | 선택한 인증 방법의 경우 다음 구성 지침을 사용합니다.[See the AWS documentation website for more details](http://docs.aws.amazon.com/ko_kr/prescriptive-guidance/latest/patterns/deploy-containerized-applications-on-aws-iot-greengrass-version-2-running-as-a-docker-container.html) | 관리자 | 

### Docker Compose로 실행
<a name="run-with-docker-compose"></a>


| 작업 | 설명 | 필요한 기술 | 
| --- | --- | --- | 
| `docker-compose.yml`를 구성합니다. | 다음과 같이 환경 변수로 `docker-compose.yml` 파일을 업데이트합니다.[See the AWS documentation website for more details](http://docs.aws.amazon.com/ko_kr/prescriptive-guidance/latest/patterns/deploy-containerized-applications-on-aws-iot-greengrass-version-2-running-as-a-docker-container.html)[See the AWS documentation website for more details](http://docs.aws.amazon.com/ko_kr/prescriptive-guidance/latest/patterns/deploy-containerized-applications-on-aws-iot-greengrass-version-2-running-as-a-docker-container.html)[See the AWS documentation website for more details](http://docs.aws.amazon.com/ko_kr/prescriptive-guidance/latest/patterns/deploy-containerized-applications-on-aws-iot-greengrass-version-2-running-as-a-docker-container.html) | DevOps 엔지니어 | 
| 컨테이너를 시작하고 확인합니다. | 포그라운드에서 시작하려면 다음 명령을 실행합니다.<br />`docker-compose up --build`<br />또는 백그라운드에서 시작하려면 다음 명령을 실행합니다.<br />`docker-compose up --build -d`<br />상태를 확인하려면 다음 명령을 실행합니다.<br />`docker-compose ps`<br />로그를 모니터링하려면 다음 명령을 실행합니다.<br />`docker-compose logs -f` | DevOps 엔지니어 | 

### Docker CLI로 실행
<a name="run-with-docker-cli"></a>


| 작업 | 설명 | 필요한 기술 | 
| --- | --- | --- | 
| Docker CLI를 사용하여 컨테이너를 실행합니다. | [See the AWS documentation website for more details](http://docs.aws.amazon.com/ko_kr/prescriptive-guidance/latest/patterns/deploy-containerized-applications-on-aws-iot-greengrass-version-2-running-as-a-docker-container.html)[See the AWS documentation website for more details](http://docs.aws.amazon.com/ko_kr/prescriptive-guidance/latest/patterns/deploy-containerized-applications-on-aws-iot-greengrass-version-2-running-as-a-docker-container.html)[See the AWS documentation website for more details](http://docs.aws.amazon.com/ko_kr/prescriptive-guidance/latest/patterns/deploy-containerized-applications-on-aws-iot-greengrass-version-2-running-as-a-docker-container.html)[See the AWS documentation website for more details](http://docs.aws.amazon.com/ko_kr/prescriptive-guidance/latest/patterns/deploy-containerized-applications-on-aws-iot-greengrass-version-2-running-as-a-docker-container.html)[See the AWS documentation website for more details](http://docs.aws.amazon.com/ko_kr/prescriptive-guidance/latest/patterns/deploy-containerized-applications-on-aws-iot-greengrass-version-2-running-as-a-docker-container.html) | DevOps 엔지니어 | 
| 컨테이너를 확인합니다. | [See the AWS documentation website for more details](http://docs.aws.amazon.com/ko_kr/prescriptive-guidance/latest/patterns/deploy-containerized-applications-on-aws-iot-greengrass-version-2-running-as-a-docker-container.html)[See the AWS documentation website for more details](http://docs.aws.amazon.com/ko_kr/prescriptive-guidance/latest/patterns/deploy-containerized-applications-on-aws-iot-greengrass-version-2-running-as-a-docker-container.html) | DevOps 엔지니어 | 

### 컨테이너화된 애플리케이션 관리
<a name="manage-containerized-applications"></a>


| 작업 | 설명 | 필요한 기술 | 
| --- | --- | --- | 
| 애플리케이션을 배포합니다. | [See the AWS documentation website for more details](http://docs.aws.amazon.com/ko_kr/prescriptive-guidance/latest/patterns/deploy-containerized-applications-on-aws-iot-greengrass-version-2-running-as-a-docker-container.html)[See the AWS documentation website for more details](http://docs.aws.amazon.com/ko_kr/prescriptive-guidance/latest/patterns/deploy-containerized-applications-on-aws-iot-greengrass-version-2-running-as-a-docker-container.html)[See the AWS documentation website for more details](http://docs.aws.amazon.com/ko_kr/prescriptive-guidance/latest/patterns/deploy-containerized-applications-on-aws-iot-greengrass-version-2-running-as-a-docker-container.html) | 앱 개발자 | 
| Docker-in-Docker에 액세스하고 테스트합니다. | [See the AWS documentation website for more details](http://docs.aws.amazon.com/ko_kr/prescriptive-guidance/latest/patterns/deploy-containerized-applications-on-aws-iot-greengrass-version-2-running-as-a-docker-container.html) | DevOps 엔지니어 | 

### (선택 사항) Amazon ECS Anywhere와 통합
<a name="optional-integrate-with-ecs-anywhere"></a>


| 작업 | 설명 | 필요한 기술 | 
| --- | --- | --- | 
| Amazon ECS 클러스터를 설정합니다. | [See the AWS documentation website for more details](http://docs.aws.amazon.com/ko_kr/prescriptive-guidance/latest/patterns/deploy-containerized-applications-on-aws-iot-greengrass-version-2-running-as-a-docker-container.html)[See the AWS documentation website for more details](http://docs.aws.amazon.com/ko_kr/prescriptive-guidance/latest/patterns/deploy-containerized-applications-on-aws-iot-greengrass-version-2-running-as-a-docker-container.html)[See the AWS documentation website for more details](http://docs.aws.amazon.com/ko_kr/prescriptive-guidance/latest/patterns/deploy-containerized-applications-on-aws-iot-greengrass-version-2-running-as-a-docker-container.html) | 관리자 | 
| Amazon ECS 작업을 배포합니다. | [See the AWS documentation website for more details](http://docs.aws.amazon.com/ko_kr/prescriptive-guidance/latest/patterns/deploy-containerized-applications-on-aws-iot-greengrass-version-2-running-as-a-docker-container.html)[See the AWS documentation website for more details](http://docs.aws.amazon.com/ko_kr/prescriptive-guidance/latest/patterns/deploy-containerized-applications-on-aws-iot-greengrass-version-2-running-as-a-docker-container.html)[See the AWS documentation website for more details](http://docs.aws.amazon.com/ko_kr/prescriptive-guidance/latest/patterns/deploy-containerized-applications-on-aws-iot-greengrass-version-2-running-as-a-docker-container.html) | 관리자 | 

### 중지 및 정리
<a name="stop-and-cleanup"></a>


| 작업 | 설명 | 필요한 기술 | 
| --- | --- | --- | 
| 컨테이너를 중지합니다. | [See the AWS documentation website for more details](http://docs.aws.amazon.com/ko_kr/prescriptive-guidance/latest/patterns/deploy-containerized-applications-on-aws-iot-greengrass-version-2-running-as-a-docker-container.html)[See the AWS documentation website for more details](http://docs.aws.amazon.com/ko_kr/prescriptive-guidance/latest/patterns/deploy-containerized-applications-on-aws-iot-greengrass-version-2-running-as-a-docker-container.html)[See the AWS documentation website for more details](http://docs.aws.amazon.com/ko_kr/prescriptive-guidance/latest/patterns/deploy-containerized-applications-on-aws-iot-greengrass-version-2-running-as-a-docker-container.html) | DevOps 엔지니어 | 

## 문제 해결
<a name="deploy-containerized-applications-on-aws-iot-greengrass-version-2-running-as-a-docker-container-troubleshooting"></a>


| 문제 | Solution | 
| --- | --- | 
| 컨테이너가 권한 오류로 시작되지 않습니다. | [See the AWS documentation website for more details](http://docs.aws.amazon.com/ko_kr/prescriptive-guidance/latest/patterns/deploy-containerized-applications-on-aws-iot-greengrass-version-2-running-as-a-docker-container.html)`--privileged`는 컨테이너에 확장 권한을 부여합니다. | 
| 자격 증명 오류와 함께 프로비저닝이 실패합니다. | 자격 증명이 올바르게 구성되었는지 확인하려면 다음 단계를 사용합니다.[See the AWS documentation website for more details](http://docs.aws.amazon.com/ko_kr/prescriptive-guidance/latest/patterns/deploy-containerized-applications-on-aws-iot-greengrass-version-2-running-as-a-docker-container.html)<br />IAM 권한에 `iot:CreateThing`, `iot:CreatePolicy`, `iot:AttachPolicy`, 및 `iam:CreateRole`가 포함되어 있는지 확인합니다`iam:AttachRolePolicy`. | 
| 컨테이너 내부의 Docker 데몬에 연결할 수 없습니다. | [See the AWS documentation website for more details](http://docs.aws.amazon.com/ko_kr/prescriptive-guidance/latest/patterns/deploy-containerized-applications-on-aws-iot-greengrass-version-2-running-as-a-docker-container.html) | 
| 컨테이너에 디스크 공간이 부족합니다. | [See the AWS documentation website for more details](http://docs.aws.amazon.com/ko_kr/prescriptive-guidance/latest/patterns/deploy-containerized-applications-on-aws-iot-greengrass-version-2-running-as-a-docker-container.html)최소 디스크 공간 보장: 기본 작업의 경우 5GB, AWS IoT SiteWise Edge의 경우 50GB | 
| 빌드 문제. | [See the AWS documentation website for more details](http://docs.aws.amazon.com/ko_kr/prescriptive-guidance/latest/patterns/deploy-containerized-applications-on-aws-iot-greengrass-version-2-running-as-a-docker-container.html) | 
| 네트워크 연결 문제. | [See the AWS documentation website for more details](http://docs.aws.amazon.com/ko_kr/prescriptive-guidance/latest/patterns/deploy-containerized-applications-on-aws-iot-greengrass-version-2-running-as-a-docker-container.html)방화벽이 아웃바운드 HTTPS(443) 및 MQTT(8883) 트래픽을 허용하는지 확인합니다. | 
| Greengrass 구성 요소가 배포되지 않습니다. | [See the AWS documentation website for more details](http://docs.aws.amazon.com/ko_kr/prescriptive-guidance/latest/patterns/deploy-containerized-applications-on-aws-iot-greengrass-version-2-running-as-a-docker-container.html)`/greengrass/v2/logs/` 디렉터리에서 구성 요소별 로그를 확인합니다. | 
| 컨테이너는 시작 직후 종료됩니다. | [See the AWS documentation website for more details](http://docs.aws.amazon.com/ko_kr/prescriptive-guidance/latest/patterns/deploy-containerized-applications-on-aws-iot-greengrass-version-2-running-as-a-docker-container.html)인 경우 필요한 모든 환경 변수가 올바르게 설정되었는지 확인합니다`PROVISION=true`. 컨테이너를 시작할 때 `--init` 플래그가 사용되는지 확인합니다. | 

## 관련 리소스
<a name="deploy-containerized-applications-on-aws-iot-greengrass-version-2-running-as-a-docker-container-resources"></a>

**AWS resources**
+ [Amazon Elastic Container Service](https://aws.amazon.com/ecs/)
+ [AWS IoT SiteWise 모델 및 자산에 대한 엣지 데이터 처리 구성](https://docs.aws.amazon.com/iot-sitewise/latest/userguide/edge-processing.html)
+ [정의 AWS IoT Greengrass](https://docs.aws.amazon.com/greengrass/v2/developerguide/what-is-iot-greengrass.html)

**기타 리소스**
+ [Docker 설명서](https://docs.docker.com/)

## 추가 정보
<a name="deploy-containerized-applications-on-aws-iot-greengrass-version-2-running-as-a-docker-container-additional"></a>
+  AWS IoT SiteWise 엣지 데이터 처리의 경우 AWS IoT Greengrass 환경 내에서 Docker를 사용할 수 있어야 합니다.
+ 중첩 컨테이너를 실행하려면 관리자 수준 자격 증명으로 AWS IoT Greengrass 컨테이너를 실행해야 합니다.