2017年1月24日火曜日

Docker コンテナなら誰でも AmazonLinux が使える


DockerHUB には Official な AmazonLinux イメージがあります。

AWSのアカウントは不要なので、誰でも使えます。

以下のようにしてイメージをローカルにダウンロードできます。
[root@centos0702 ~]# docker pull amazonlinux
Using default tag: latest
Trying to pull repository docker.io/library/amazonlinux ...
latest: Pulling from docker.io/library/amazonlinux
c9141092a50d: Pull complete
Digest: sha256:2010c88ac1e7c118d61793eec71dcfe0e276d72b38dd86bd3e49da1f8c48bf54
Status: Downloaded newer image for docker.io/amazonlinux:latest
[root@centos0702 ~]# docker images
REPOSITORY              TAG                 IMAGE ID            CREATED             SIZE
centos6_ec2             2                   58e51bade44e        33 hours ago        633 MB
docker.io/amazonlinux   latest              8ae6f52035b5        3 weeks ago         292.3 MB
docker.io/centos        6                   8315978ceaaa        11 weeks ago        194.6 MB

コンテナを起動して、OSバージョンを確認してみます。
[root@centos0702 ~]# docker run -it amazonlinux /bin/bash
bash-4.2# cat /etc/system-release
Amazon Linux AMI release 2016.09

軽量すぎて、psやvi、more コマンドがないので、インストールします。
bash-4.2# yum install util-linux procps vi

コマンドがどのパッケージに含まれているかは、ホストのCentOSで調べます。
[root@centos0702 ~]# rpm -qf /usr/bin/vi
vim-minimal-7.4.160-1.el7_3.1.x86_64