Last active
August 29, 2015 14:11
-
-
Save masayuki5160/7cc24dee1c550206fc34 to your computer and use it in GitHub Desktop.
AWSでDockerをためしてみる
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1. まずはDockeをインストール | |
$ sudo yum install -y docker | |
2. Dockerのデーモンをスタート | |
$ sudo service docker start | |
3. Docker 公式サイトで提供されているチュートリアル用のコンテナを取得 | |
$ sudo docker pull learn/tutorial | |
-------------------------------------------------- | |
[ec2-user@ip-172-16-0-19 ~]$ sudo docker pull learn/tutorial | |
Pulling repository learn/tutorial | |
8dbd9e392a96: Download complete | |
Status: Downloaded newer image for learn/tutorial:latest | |
-------------------------------------------------- | |
4. 取得した結果を確認 | |
$ sudo docker images | |
-------------------------------------------------- | |
[ec2-user@ip-172-16-0-19 ~]$ sudo docker images | |
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE | |
learn/tutorial latest 8dbd9e392a96 20 months ago 128 MB | |
-------------------------------------------------- | |
5. 取得したコンテナで動作チェック("docker run image名 コマンド" でimage名のコンテナ内でコマンド実行することになる) | |
$ sudo docker run learn/tutorial echo Hello, Docker! | |
-------------------------------------------------- | |
[ec2-user@ip-172-16-0-19 ~]$ sudo docker run learn/tutorial echo Hello, Docker! | |
Hello, Docker! | |
-------------------------------------------------- | |
6. "learn/tutorial"コンテナにpingをインストール | |
$ sudo docker run learn/tutorial apt-get install -y ping | |
-------------------------------------------------- | |
[ec2-user@ip-172-16-0-19 ~]$ sudo docker run learn/tutorial apt-get install -y ping | |
Reading package lists... | |
Building dependency tree... | |
The following NEW packages will be installed: | |
iputils-ping | |
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded. | |
Need to get 56.1 kB of archives. | |
After this operation, 143 kB of additional disk space will be used. | |
Get:1 http://archive.ubuntu.com/ubuntu/ precise/main iputils-ping amd64 3:20101006-1ubuntu1 [56.1 kB] | |
debconf: delaying package configuration, since apt-utils is not installed | |
Fetched 56.1 kB in 1s (49.5 kB/s) | |
Selecting previously unselected package iputils-ping. | |
(Reading database ... 7545 files and directories currently installed.) | |
Unpacking iputils-ping (from .../iputils-ping_3%3a20101006-1ubuntu1_amd64.deb) ... | |
Setting up iputils-ping (3:20101006-1ubuntu1) ... | |
-------------------------------------------------- | |
7. コンテナの一覧を確認 | |
$ sudo docker ps -l | |
-------------------------------------------------- | |
[ec2-user@ip-172-16-0-19 ~]$ sudo docker ps -l | |
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES | |
5961c6ae223f learn/tutorial:latest "apt-get install -y 58 seconds ago Exited (0) 56 seconds ago clever_lalande | |
-------------------------------------------------- | |
8. コンテナの保存(commitのあとに上記ps -lで確認できるCONTAINER IDの上4ケタをセット。そのあとにコンテナ名をセット) | |
$ sudo docker commit 5961 learn/ping | |
9. コンテナの確認 | |
$ sudo docker images | |
-------------------------------------------------- | |
[ec2-user@ip-172-16-0-19 ~]$ sudo docker images | |
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE | |
learn/ping latest 5e6ea157f99a 15 seconds ago 139.5 MB | |
learn/tutorial latest 8dbd9e392a96 20 months ago 128 MB | |
-------------------------------------------------- | |
10. 作成したコンテナ上でpingしてみる(ちゃんと保存できてればはじめからpingはいったコンテナだよね、て確認) | |
$ sudo docker run learn/ping ping hogehoge.com | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
参考↓てかまんまです。
AWSでDockerを使ってみよう!
http://www.techscore.com/blog/2014/07/08/try-docker-on-aws/