AWS入門、ついでにDocker入門


目次

1.概要
2.Dockerとは
3.動かしてみよう
4.管理してみよう


1.概要

・AWS/Docker初心者が
 AWSを使ってDockerを動かしてみました。

・AWSを使って様々な製品、技術に触れるハードルが下がればと思います。


2.Dockerとは

コンテナ型の仮想化環境を
作成、配布、実行するためのプラットフォーム

ホストOS上で仮想化するので
○起動が高速、環境構築が簡単・・・
△ホストOSと同一のOSしか使えない・・・

Dockerの起動イメージ


3.Dockerを動かしてみよう

(1)AWS EC2の立ち上げ
(2)Dockerをインストール
(3)DockerイメージからDockerコンテナを動かす

(1)AWS EC2の立ち上げ
EC2コンソール上からインスタンスを立ち上げる。
(今回はAmazon Linux 2)

(2)Dockerをインストール
AWS提供リポジトリからDockerが取得できる。
(数秒で完了)

docker1.log
$ sudo yum install docker
読み込んだプラグイン:extras_suggestions, langpacks, priorities, update-motd
~中略~
インストール:docker.x86_64 0:18.09.9ce-2.amzn2
依存性関連をインストールしました:
  containerd.x86_64 0:1.2.6-1.amzn2              
  libcgroup.x86_64 0:0.41-21.amzn2   
  pigz.x86_64 0:2.3.4-1.amzn2.0.1                
  runc.x86_64 0:1.0.0-0.1.20190510.git2b18fe1.amzn2
完了しました!

(3)DockerイメージからDockerコンテナを動かしてみる
「Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world」
→ローカルにhello-worldイメージが存在しないため、
 DockerHubのライブラリから取得。

docker2.log
$sudo docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
1b930d010525: Pull complete 
Digest: sha256:4fe721ccc2e8dc7362278a29dc660d833570ec2682f4e4194f4ee23e415e1064
Status: Downloaded newer image for hello-world:latest

Hello from Docker!
This message shows that your installation appears to be working correctly.

4.Dockerを管理してみよう

(1)DockerHub
(2)Amazon ECS/ECR

(1)DockerHub
Dockerイメージを公開・共有できるサービス

(2)Amazon ECS/ECR
ECS:Amazon Elastic Container Service
Dockerコンテナの管理サービス。

ECR:Amazon Elastic Container Registry
Dockerイメージの管理サービス。