Docker実践活用ガイド 学習メモPart01

# はじめに
Docekrを学びたくて、本を買ったもののDockerをMacに入れただけで進んでなかったので、本でやった内容を書いていきます。
参考書は、[こちら](http://amzn.asia/4sDxuIr)です

# 学習メモ
書籍のPart6をやっていきました。

## 6.1 Dockerイメージとは
* Dockerイメージは、コンテナの大元のものでファイルシステム、実行環境、設定情報をまとめたもの。
* これが特徴の一つである、冪等性に寄与する。
* Dockerイメージに対する主な操作は、次の通り
    * Dockerイメージをダウンロードする　： `docekr pull`
    * Dockerイメージを使ってコンテナを作成する ： `docker run`
    * Dockerイメージを作成する : `docker commit`
    * Dokcerfileで記述した構築方法をもとにDokcerイメージを自動生成する : `docker build`
    * DockerイメージをDocker Hub(Dockerレジストリ)に保存する : `docker push`

## 6.2 Dockerイメージのダウンロード
* イメージのダウンロードと、イメージ一覧は次のコマンドで確認できます。

```bash:コマンド
$ docker pull ubuntu
Using default tag: latest
latest: Pulling from library/ubuntu
d54efb8db41d: Pull complete
f8b845f45a87: Pull complete
e8db7bf7c39f: Pull complete
9654c40e9079: Pull complete
6d9ef359eaaa: Pull complete
Digest: sha256:dd7808d8792c9841d0b460122f1acf0a2dd1f56404f8d1e56298048885e45535
Status: Downloaded newer image for ubuntu:latest
$ docker images
REPOSITORY                       TAG                 IMAGE ID            CREATED             SIZE
ubuntu                           latest              0ef2e08ed3fa        3 weeks ago         130 MB
nginx                            latest              ba6bed934df2        6 months ago        181 MB
~中略~
```

* コンテナの中身を確認するコマンド。

```bash:コマンド
$ docker run -i -t ubuntu cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=16.04
DISTRIB_CODENAME=xenial
DISTRIB_DESCRIPTION="Ubuntu 16.04.2 LTS"
```

## 6.3 コンテナからのDockerイメージ作成
いよいよ、自分でイメージを作っていきます。
手順は、
1. コンテナをシェルで実行する
2. コンテナ内でアプリのインストールなどを行い、ファイルを変更する
3. コンテナからDockerイメージを作成する

### 1. コンテナをシェルで実行する
```bash:コマンド
$ docker run -i -t ubuntu /bin/bash
root@1d1da0a0d8f6:/#
```

### 2.コンテナにアプリをインストールする
パッケージのアップデートと、Node.jsの実行環境を整えます。

```bash:コマンド
root@1d1da0a0d8f6:/# apt-get update
Get:1 http://archive.ubuntu.com/ubuntu xenial InRelease [247 kB]
Get:2 http://archive.ubuntu.com/ubuntu xenial-updates InRelease [102 kB]
Get:3 http://archive.ubuntu.com/ubuntu xenial-security InRelease [102 kB]
Get:4 http://archive.ubuntu.com/ubuntu xenial/main Sources [1103 kB]
Get:5 http://archive.ubuntu.com/ubuntu xenial/restricted Sources [5179 B]
Get:6 http://archive.ubuntu.com/ubuntu xenial/universe Sources [9802 kB]
Get:7 http://archive.ubuntu.com/ubuntu xenial/main amd64 Packages [1558 kB]
Get:8 http://archive.ubuntu.com/ubuntu xenial/restricted amd64 Packages [14.1 kB]
Get:9 http://archive.ubuntu.com/ubuntu xenial/universe amd64 Packages [9827 kB]
Get:10 http://archive.ubuntu.com/ubuntu xenial-updates/main Sources [299 kB]
Get:11 http://archive.ubuntu.com/ubuntu xenial-updates/restricted Sources [3202 B]
Get:12 http://archive.ubuntu.com/ubuntu xenial-updates/universe Sources [183 kB]
Get:13 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 Packages [631 kB]
Get:14 http://archive.ubuntu.com/ubuntu xenial-updates/restricted amd64 Packages [13.2 kB]
Get:15 http://archive.ubuntu.com/ubuntu xenial-updates/universe amd64 Packages [560 kB]
Get:16 http://archive.ubuntu.com/ubuntu xenial-security/main Sources [78.6 kB]
Get:17 http://archive.ubuntu.com/ubuntu xenial-security/restricted Sources [2779 B]
Get:18 http://archive.ubuntu.com/ubuntu xenial-security/universe Sources [28.5 kB]
Get:19 http://archive.ubuntu.com/ubuntu xenial-security/main amd64 Packages [290 kB]
Get:20 http://archive.ubuntu.com/ubuntu xenial-security/restricted amd64 Packages [12.8 kB]
Get:21 http://archive.ubuntu.com/ubuntu xenial-security/universe amd64 Packages [120 kB]
Fetched 25.0 MB in 54s (462 kB/s)
Reading package lists... Done
root@1d1da0a0d8f6:/# apt-get install -y curl
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
  ca-certificates krb5-locales libasn1-8-heimdal libcurl3-gnutls libffi6 libgmp10 libgnutls30 libgssapi-krb5-2
  libgssapi3-heimdal libhcrypto4-heimdal libheimbase1-heimdal libheimntlm0-heimdal libhogweed4 libhx509-5-heimdal libidn11
  libk5crypto3 libkeyutils1 libkrb5-26-heimdal libkrb5-3 libkrb5support0 libldap-2.4-2 libnettle6 libp11-kit0
  libroken18-heimdal librtmp1 libsasl2-2 libsasl2-modules libsasl2-modules-db libsqlite3-0 libssl1.0.0 libtasn1-6
  libwind0-heimdal openssl
Suggested packages:
  gnutls-bin krb5-doc krb5-user libsasl2-modules-otp libsasl2-modules-ldap libsasl2-modules-sql libsasl2-modules-gssapi-mit
  | libsasl2-modules-gssapi-heimdal
The following NEW packages will be installed:
  ca-certificates curl krb5-locales libasn1-8-heimdal libcurl3-gnutls libffi6 libgmp10 libgnutls30 libgssapi-krb5-2
  libgssapi3-heimdal libhcrypto4-heimdal libheimbase1-heimdal libheimntlm0-heimdal libhogweed4 libhx509-5-heimdal libidn11
  libk5crypto3 libkeyutils1 libkrb5-26-heimdal libkrb5-3 libkrb5support0 libldap-2.4-2 libnettle6 libp11-kit0
  libroken18-heimdal librtmp1 libsasl2-2 libsasl2-modules libsasl2-modules-db libsqlite3-0 libssl1.0.0 libtasn1-6
  libwind0-heimdal openssl
0 upgraded, 34 newly installed, 0 to remove and 6 not upgraded.
Need to get 5363 kB of archives.
After this operation, 19.1 MB of additional disk space will be used.
Get:1 http://archive.ubuntu.com/ubuntu xenial/main amd64 libffi6 amd64 3.2.1-4 [17.8 kB]
Get:2 http://archive.ubuntu.com/ubuntu xenial/main amd64 libgmp10 amd64 2:6.1.0+dfsg-2 [240 kB]
Get:3 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libnettle6 amd64 3.2-1ubuntu0.16.04.1 [93.5 kB]
Get:4 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libhogweed4 amd64 3.2-1ubuntu0.16.04.1 [136 kB]
Get:5 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libidn11 amd64 1.32-3ubuntu1.1 [45.6 kB]
Get:6 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libp11-kit0 amd64 0.23.2-5~ubuntu16.04.1 [105 kB]
Get:7 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libtasn1-6 amd64 4.7-3ubuntu0.16.04.1 [43.2 kB]
Get:8 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libgnutls30 amd64 3.4.10-4ubuntu1.2 [547 kB]
Get:9 http://archive.ubuntu.com/ubuntu xenial/main amd64 libsqlite3-0 amd64 3.11.0-1ubuntu1 [396 kB]
Get:10 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libssl1.0.0 amd64 1.0.2g-1ubuntu4.6 [1082 kB]
Get:11 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 openssl amd64 1.0.2g-1ubuntu4.6 [492 kB]
Get:12 http://archive.ubuntu.com/ubuntu xenial/main amd64 ca-certificates all 20160104ubuntu1 [191 kB]
Get:13 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 krb5-locales all 1.13.2+dfsg-5ubuntu2 [13.2 kB]
Get:14 http://archive.ubuntu.com/ubuntu xenial/main amd64 libroken18-heimdal amd64 1.7~git20150920+dfsg-4ubuntu1 [41.2 kB]
Get:15 http://archive.ubuntu.com/ubuntu xenial/main amd64 libasn1-8-heimdal amd64 1.7~git20150920+dfsg-4ubuntu1 [174 kB]
Get:16 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libkrb5support0 amd64 1.13.2+dfsg-5ubuntu2 [30.8 kB]
Get:17 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libk5crypto3 amd64 1.13.2+dfsg-5ubuntu2 [81.2 kB]
Get:18 http://archive.ubuntu.com/ubuntu xenial/main amd64 libkeyutils1 amd64 1.5.9-8ubuntu1 [9904 B]
Get:19 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libkrb5-3 amd64 1.13.2+dfsg-5ubuntu2 [273 kB]
Get:20 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libgssapi-krb5-2 amd64 1.13.2+dfsg-5ubuntu2 [120 kB]
Get:21 http://archive.ubuntu.com/ubuntu xenial/main amd64 libhcrypto4-heimdal amd64 1.7~git20150920+dfsg-4ubuntu1 [84.9 kB]
Get:22 http://archive.ubuntu.com/ubuntu xenial/main amd64 libheimbase1-heimdal amd64 1.7~git20150920+dfsg-4ubuntu1 [29.2 kB]
Get:23 http://archive.ubuntu.com/ubuntu xenial/main amd64 libwind0-heimdal amd64 1.7~git20150920+dfsg-4ubuntu1 [48.2 kB]
Get:24 http://archive.ubuntu.com/ubuntu xenial/main amd64 libhx509-5-heimdal amd64 1.7~git20150920+dfsg-4ubuntu1 [107 kB]
Get:25 http://archive.ubuntu.com/ubuntu xenial/main amd64 libkrb5-26-heimdal amd64 1.7~git20150920+dfsg-4ubuntu1 [202 kB]
Get:26 http://archive.ubuntu.com/ubuntu xenial/main amd64 libheimntlm0-heimdal amd64 1.7~git20150920+dfsg-4ubuntu1 [15.1 kB]
Get:27 http://archive.ubuntu.com/ubuntu xenial/main amd64 libgssapi3-heimdal amd64 1.7~git20150920+dfsg-4ubuntu1 [96.1 kB]
Get:28 http://archive.ubuntu.com/ubuntu xenial/main amd64 libsasl2-modules-db amd64 2.1.26.dfsg1-14build1 [14.5 kB]
Get:29 http://archive.ubuntu.com/ubuntu xenial/main amd64 libsasl2-2 amd64 2.1.26.dfsg1-14build1 [48.7 kB]
Get:30 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libldap-2.4-2 amd64 2.4.42+dfsg-2ubuntu3.1 [161 kB]
Get:31 http://archive.ubuntu.com/ubuntu xenial/main amd64 librtmp1 amd64 2.4+20151223.gitfa8646d-1build1 [53.9 kB]
Get:32 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libcurl3-gnutls amd64 7.47.0-1ubuntu2.2 [184 kB]
Get:33 http://archive.ubuntu.com/ubuntu xenial/main amd64 libsasl2-modules amd64 2.1.26.dfsg1-14build1 [47.5 kB]
Get:34 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 curl amd64 7.47.0-1ubuntu2.2 [139 kB]
Fetched 5363 kB in 13s (401 kB/s)
debconf: delaying package configuration, since apt-utils is not installed
Selecting previously unselected package libffi6:amd64.
(Reading database ... 7256 files and directories currently installed.)
Preparing to unpack .../libffi6_3.2.1-4_amd64.deb ...
Unpacking libffi6:amd64 (3.2.1-4) ...
Selecting previously unselected package libgmp10:amd64.
Preparing to unpack .../libgmp10_2%3a6.1.0+dfsg-2_amd64.deb ...
Unpacking libgmp10:amd64 (2:6.1.0+dfsg-2) ...
Selecting previously unselected package libnettle6:amd64.
Preparing to unpack .../libnettle6_3.2-1ubuntu0.16.04.1_amd64.deb ...
Unpacking libnettle6:amd64 (3.2-1ubuntu0.16.04.1) ...
Selecting previously unselected package libhogweed4:amd64.
Preparing to unpack .../libhogweed4_3.2-1ubuntu0.16.04.1_amd64.deb ...
Unpacking libhogweed4:amd64 (3.2-1ubuntu0.16.04.1) ...
Selecting previously unselected package libidn11:amd64.
Preparing to unpack .../libidn11_1.32-3ubuntu1.1_amd64.deb ...
Unpacking libidn11:amd64 (1.32-3ubuntu1.1) ...
Selecting previously unselected package libp11-kit0:amd64.
Preparing to unpack .../libp11-kit0_0.23.2-5~ubuntu16.04.1_amd64.deb ...
Unpacking libp11-kit0:amd64 (0.23.2-5~ubuntu16.04.1) ...
Selecting previously unselected package libtasn1-6:amd64.
Preparing to unpack .../libtasn1-6_4.7-3ubuntu0.16.04.1_amd64.deb ...
Unpacking libtasn1-6:amd64 (4.7-3ubuntu0.16.04.1) ...
Selecting previously unselected package libgnutls30:amd64.
Preparing to unpack .../libgnutls30_3.4.10-4ubuntu1.2_amd64.deb ...
Unpacking libgnutls30:amd64 (3.4.10-4ubuntu1.2) ...
Selecting previously unselected package libsqlite3-0:amd64.
Preparing to unpack .../libsqlite3-0_3.11.0-1ubuntu1_amd64.deb ...
Unpacking libsqlite3-0:amd64 (3.11.0-1ubuntu1) ...
Selecting previously unselected package libssl1.0.0:amd64.
Preparing to unpack .../libssl1.0.0_1.0.2g-1ubuntu4.6_amd64.deb ...
Unpacking libssl1.0.0:amd64 (1.0.2g-1ubuntu4.6) ...
Selecting previously unselected package openssl.
Preparing to unpack .../openssl_1.0.2g-1ubuntu4.6_amd64.deb ...
Unpacking openssl (1.0.2g-1ubuntu4.6) ...
Selecting previously unselected package ca-certificates.
Preparing to unpack .../ca-certificates_20160104ubuntu1_all.deb ...
Unpacking ca-certificates (20160104ubuntu1) ...
Selecting previously unselected package krb5-locales.
Preparing to unpack .../krb5-locales_1.13.2+dfsg-5ubuntu2_all.deb ...
Unpacking krb5-locales (1.13.2+dfsg-5ubuntu2) ...
Selecting previously unselected package libroken18-heimdal:amd64.
Preparing to unpack .../libroken18-heimdal_1.7~git20150920+dfsg-4ubuntu1_amd64.deb ...
Unpacking libroken18-heimdal:amd64 (1.7~git20150920+dfsg-4ubuntu1) ...
Selecting previously unselected package libasn1-8-heimdal:amd64.
Preparing to unpack .../libasn1-8-heimdal_1.7~git20150920+dfsg-4ubuntu1_amd64.deb ...
Unpacking libasn1-8-heimdal:amd64 (1.7~git20150920+dfsg-4ubuntu1) ...
Selecting previously unselected package libkrb5support0:amd64.
Preparing to unpack .../libkrb5support0_1.13.2+dfsg-5ubuntu2_amd64.deb ...
Unpacking libkrb5support0:amd64 (1.13.2+dfsg-5ubuntu2) ...
Selecting previously unselected package libk5crypto3:amd64.
Preparing to unpack .../libk5crypto3_1.13.2+dfsg-5ubuntu2_amd64.deb ...
Unpacking libk5crypto3:amd64 (1.13.2+dfsg-5ubuntu2) ...
Selecting previously unselected package libkeyutils1:amd64.
Preparing to unpack .../libkeyutils1_1.5.9-8ubuntu1_amd64.deb ...
Unpacking libkeyutils1:amd64 (1.5.9-8ubuntu1) ...
Selecting previously unselected package libkrb5-3:amd64.
Preparing to unpack .../libkrb5-3_1.13.2+dfsg-5ubuntu2_amd64.deb ...
Unpacking libkrb5-3:amd64 (1.13.2+dfsg-5ubuntu2) ...
Selecting previously unselected package libgssapi-krb5-2:amd64.
Preparing to unpack .../libgssapi-krb5-2_1.13.2+dfsg-5ubuntu2_amd64.deb ...
Unpacking libgssapi-krb5-2:amd64 (1.13.2+dfsg-5ubuntu2) ...
Selecting previously unselected package libhcrypto4-heimdal:amd64.
Preparing to unpack .../libhcrypto4-heimdal_1.7~git20150920+dfsg-4ubuntu1_amd64.deb ...
Unpacking libhcrypto4-heimdal:amd64 (1.7~git20150920+dfsg-4ubuntu1) ...
Selecting previously unselected package libheimbase1-heimdal:amd64.
Preparing to unpack .../libheimbase1-heimdal_1.7~git20150920+dfsg-4ubuntu1_amd64.deb ...
Unpacking libheimbase1-heimdal:amd64 (1.7~git20150920+dfsg-4ubuntu1) ...
Selecting previously unselected package libwind0-heimdal:amd64.
Preparing to unpack .../libwind0-heimdal_1.7~git20150920+dfsg-4ubuntu1_amd64.deb ...
Unpacking libwind0-heimdal:amd64 (1.7~git20150920+dfsg-4ubuntu1) ...
Selecting previously unselected package libhx509-5-heimdal:amd64.
Preparing to unpack .../libhx509-5-heimdal_1.7~git20150920+dfsg-4ubuntu1_amd64.deb ...
Unpacking libhx509-5-heimdal:amd64 (1.7~git20150920+dfsg-4ubuntu1) ...
Selecting previously unselected package libkrb5-26-heimdal:amd64.
Preparing to unpack .../libkrb5-26-heimdal_1.7~git20150920+dfsg-4ubuntu1_amd64.deb ...
Unpacking libkrb5-26-heimdal:amd64 (1.7~git20150920+dfsg-4ubuntu1) ...
Selecting previously unselected package libheimntlm0-heimdal:amd64.
Preparing to unpack .../libheimntlm0-heimdal_1.7~git20150920+dfsg-4ubuntu1_amd64.deb ...
Unpacking libheimntlm0-heimdal:amd64 (1.7~git20150920+dfsg-4ubuntu1) ...
Selecting previously unselected package libgssapi3-heimdal:amd64.
Preparing to unpack .../libgssapi3-heimdal_1.7~git20150920+dfsg-4ubuntu1_amd64.deb ...
Unpacking libgssapi3-heimdal:amd64 (1.7~git20150920+dfsg-4ubuntu1) ...
Selecting previously unselected package libsasl2-modules-db:amd64.
Preparing to unpack .../libsasl2-modules-db_2.1.26.dfsg1-14build1_amd64.deb ...
Unpacking libsasl2-modules-db:amd64 (2.1.26.dfsg1-14build1) ...
Selecting previously unselected package libsasl2-2:amd64.
Preparing to unpack .../libsasl2-2_2.1.26.dfsg1-14build1_amd64.deb ...
Unpacking libsasl2-2:amd64 (2.1.26.dfsg1-14build1) ...
Selecting previously unselected package libldap-2.4-2:amd64.
Preparing to unpack .../libldap-2.4-2_2.4.42+dfsg-2ubuntu3.1_amd64.deb ...
Unpacking libldap-2.4-2:amd64 (2.4.42+dfsg-2ubuntu3.1) ...
Selecting previously unselected package librtmp1:amd64.
Preparing to unpack .../librtmp1_2.4+20151223.gitfa8646d-1build1_amd64.deb ...
Unpacking librtmp1:amd64 (2.4+20151223.gitfa8646d-1build1) ...
Selecting previously unselected package libcurl3-gnutls:amd64.
Preparing to unpack .../libcurl3-gnutls_7.47.0-1ubuntu2.2_amd64.deb ...
Unpacking libcurl3-gnutls:amd64 (7.47.0-1ubuntu2.2) ...
Selecting previously unselected package libsasl2-modules:amd64.
Preparing to unpack .../libsasl2-modules_2.1.26.dfsg1-14build1_amd64.deb ...
Unpacking libsasl2-modules:amd64 (2.1.26.dfsg1-14build1) ...
Selecting previously unselected package curl.
Preparing to unpack .../curl_7.47.0-1ubuntu2.2_amd64.deb ...
Unpacking curl (7.47.0-1ubuntu2.2) ...
Processing triggers for libc-bin (2.23-0ubuntu5) ...
Setting up libffi6:amd64 (3.2.1-4) ...
Setting up libgmp10:amd64 (2:6.1.0+dfsg-2) ...
Setting up libnettle6:amd64 (3.2-1ubuntu0.16.04.1) ...
Setting up libhogweed4:amd64 (3.2-1ubuntu0.16.04.1) ...
Setting up libidn11:amd64 (1.32-3ubuntu1.1) ...
Setting up libp11-kit0:amd64 (0.23.2-5~ubuntu16.04.1) ...
Setting up libtasn1-6:amd64 (4.7-3ubuntu0.16.04.1) ...
Setting up libgnutls30:amd64 (3.4.10-4ubuntu1.2) ...
Setting up libsqlite3-0:amd64 (3.11.0-1ubuntu1) ...
Setting up libssl1.0.0:amd64 (1.0.2g-1ubuntu4.6) ...
debconf: unable to initialize frontend: Dialog
debconf: (No usable dialog-like program is installed, so the dialog based frontend cannot be used. at /usr/share/perl5/Debconf/FrontEnd/Dialog.pm line 76.)
debconf: falling back to frontend: Readline
debconf: unable to initialize frontend: Readline
debconf: (Can't locate Term/ReadLine.pm in @INC (you may need to install the Term::ReadLine module) (@INC contains: /etc/perl /usr/local/lib/x86_64-linux-gnu/perl/5.22.1 /usr/local/share/perl/5.22.1 /usr/lib/x86_64-linux-gnu/perl5/5.22 /usr/share/perl5 /usr/lib/x86_64-linux-gnu/perl/5.22 /usr/share/perl/5.22 /usr/local/lib/site_perl /usr/lib/x86_64-linux-gnu/perl-base .) at /usr/share/perl5/Debconf/FrontEnd/Readline.pm line 7.)
debconf: falling back to frontend: Teletype
Setting up openssl (1.0.2g-1ubuntu4.6) ...
Setting up ca-certificates (20160104ubuntu1) ...
debconf: unable to initialize frontend: Dialog
debconf: (No usable dialog-like program is installed, so the dialog based frontend cannot be used. at /usr/share/perl5/Debconf/FrontEnd/Dialog.pm line 76.)
debconf: falling back to frontend: Readline
debconf: unable to initialize frontend: Readline
debconf: (Can't locate Term/ReadLine.pm in @INC (you may need to install the Term::ReadLine module) (@INC contains: /etc/perl /usr/local/lib/x86_64-linux-gnu/perl/5.22.1 /usr/local/share/perl/5.22.1 /usr/lib/x86_64-linux-gnu/perl5/5.22 /usr/share/perl5 /usr/lib/x86_64-linux-gnu/perl/5.22 /usr/share/perl/5.22 /usr/local/lib/site_perl /usr/lib/x86_64-linux-gnu/perl-base .) at /usr/share/perl5/Debconf/FrontEnd/Readline.pm line 7.)
debconf: falling back to frontend: Teletype
Setting up krb5-locales (1.13.2+dfsg-5ubuntu2) ...
Setting up libroken18-heimdal:amd64 (1.7~git20150920+dfsg-4ubuntu1) ...
Setting up libasn1-8-heimdal:amd64 (1.7~git20150920+dfsg-4ubuntu1) ...
Setting up libkrb5support0:amd64 (1.13.2+dfsg-5ubuntu2) ...
Setting up libk5crypto3:amd64 (1.13.2+dfsg-5ubuntu2) ...
Setting up libkeyutils1:amd64 (1.5.9-8ubuntu1) ...
Setting up libkrb5-3:amd64 (1.13.2+dfsg-5ubuntu2) ...
Setting up libgssapi-krb5-2:amd64 (1.13.2+dfsg-5ubuntu2) ...
Setting up libhcrypto4-heimdal:amd64 (1.7~git20150920+dfsg-4ubuntu1) ...
Setting up libheimbase1-heimdal:amd64 (1.7~git20150920+dfsg-4ubuntu1) ...
Setting up libwind0-heimdal:amd64 (1.7~git20150920+dfsg-4ubuntu1) ...
Setting up libhx509-5-heimdal:amd64 (1.7~git20150920+dfsg-4ubuntu1) ...
Setting up libkrb5-26-heimdal:amd64 (1.7~git20150920+dfsg-4ubuntu1) ...
Setting up libheimntlm0-heimdal:amd64 (1.7~git20150920+dfsg-4ubuntu1) ...
Setting up libgssapi3-heimdal:amd64 (1.7~git20150920+dfsg-4ubuntu1) ...
Setting up libsasl2-modules-db:amd64 (2.1.26.dfsg1-14build1) ...
Setting up libsasl2-2:amd64 (2.1.26.dfsg1-14build1) ...
Setting up libldap-2.4-2:amd64 (2.4.42+dfsg-2ubuntu3.1) ...
Setting up librtmp1:amd64 (2.4+20151223.gitfa8646d-1build1) ...
Setting up libcurl3-gnutls:amd64 (7.47.0-1ubuntu2.2) ...
Setting up libsasl2-modules:amd64 (2.1.26.dfsg1-14build1) ...
Setting up curl (7.47.0-1ubuntu2.2) ...
Processing triggers for libc-bin (2.23-0ubuntu5) ...
Processing triggers for ca-certificates (20160104ubuntu1) ...
Updating certificates in /etc/ssl/certs...
173 added, 0 removed; done.
Running hooks in /etc/ca-certificates/update.d...
done.
root@1d1da0a0d8f6:/#
root@1d1da0a0d8f6:/# curl -sL https://deb.nodesource.com/setup_4.x | bash -

## Installing the NodeSource Node.js v4.x LTS Argon repo...


## Populating apt-get cache...

+ apt-get update
Hit:1 http://archive.ubuntu.com/ubuntu xenial InRelease
Get:2 http://archive.ubuntu.com/ubuntu xenial-updates InRelease [102 kB]
Get:3 http://archive.ubuntu.com/ubuntu xenial-security InRelease [102 kB]
Fetched 204 kB in 1s (115 kB/s)
Reading package lists... Done

## Installing packages required for setup: apt-transport-https lsb-release...

+ apt-get install -y apt-transport-https lsb-release > /dev/null 2>&1

## Confirming "xenial" is supported...

+ curl -sLf -o /dev/null 'https://deb.nodesource.com/node_4.x/dists/xenial/Release'

## Adding the NodeSource signing key to your keyring...

+ curl -s https://deb.nodesource.com/gpgkey/nodesource.gpg.key | apt-key add -
OK

## Creating apt sources list file for the NodeSource Node.js v4.x LTS Argon repo...

+ echo 'deb https://deb.nodesource.com/node_4.x xenial main' > /etc/apt/sources.list.d/nodesource.list
+ echo 'deb-src https://deb.nodesource.com/node_4.x xenial main' >> /etc/apt/sources.list.d/nodesource.list

## Running `apt-get update` for you...

+ apt-get update
Get:1 https://deb.nodesource.com/node_4.x xenial InRelease [3914 B]
Hit:2 http://archive.ubuntu.com/ubuntu xenial InRelease
Get:3 https://deb.nodesource.com/node_4.x xenial/main Sources [765 B]
Get:4 http://archive.ubuntu.com/ubuntu xenial-updates InRelease [102 kB]
Get:5 https://deb.nodesource.com/node_4.x xenial/main amd64 Packages [965 B]
Get:6 http://archive.ubuntu.com/ubuntu xenial-security InRelease [102 kB]
Fetched 210 kB in 3s (60.2 kB/s)
Reading package lists... Done

## Run `apt-get install nodejs` (as root) to install Node.js v4.x LTS Argon and npm
root@1d1da0a0d8f6:/# apt-get install -y node.js
Reading package lists... Done
Building dependency tree
Reading state information... Done
Note, selecting 'node-jsv' for regex 'node.js'
Note, selecting 'node-jsdom' for regex 'node.js'
Note, selecting 'node-jsesc' for regex 'node.js'
Note, selecting 'node-json-stringify-safe' for regex 'node.js'
Note, selecting 'node-jscoverage' for regex 'node.js'
Note, selecting 'node-jssip' for regex 'node.js'
Note, selecting 'node-jsonparse' for regex 'node.js'
The following additional packages will be installed:
  ifupdown iproute2 isc-dhcp-client isc-dhcp-common javascript-common libatm1 libdns-export162 libgdbm3 libisc-export160
  libjs-bowser libjs-events libjs-inherits libjs-is-typedarray libjs-jssip libjs-merge libjs-node-uuid libjs-rtcninja
  libjs-sdp-transform libjs-typedarray-to-buffer libjs-util libjs-websocket libmnl0 libperl5.22 libxtables11 netbase node-async
  node-bowser node-combined-stream node-contextify node-cookie-jar node-cssom node-debug node-delayed-stream node-events
  node-forever-agent node-form-data node-htmlparser node-inherits node-is-typedarray node-merge node-mime node-nan
  node-node-uuid node-qs node-request node-rtcninja node-sdp-transform node-tunnel-agent node-typedarray-to-buffer node-util
  node-websocket nodejs perl perl-modules-5.22 rename rlwrap
Suggested packages:
  ppp rdnssd iproute2-doc resolvconf avahi-autoipd isc-dhcp-client-ddns apparmor apache2 | lighttpd | httpd node-hawk
  node-aws-sign node-oauth-sign node-http-signature perl-doc libterm-readline-gnu-perl | libterm-readline-perl-perl make
The following NEW packages will be installed:
  ifupdown iproute2 isc-dhcp-client isc-dhcp-common javascript-common libatm1 libdns-export162 libgdbm3 libisc-export160
  libjs-bowser libjs-events libjs-inherits libjs-is-typedarray libjs-jssip libjs-merge libjs-node-uuid libjs-rtcninja
  libjs-sdp-transform libjs-typedarray-to-buffer libjs-util libjs-websocket libmnl0 libperl5.22 libxtables11 netbase node-async
  node-bowser node-combined-stream node-contextify node-cookie-jar node-cssom node-debug node-delayed-stream node-events
  node-forever-agent node-form-data node-htmlparser node-inherits node-is-typedarray node-jsdom node-jsesc
  node-json-stringify-safe node-jsonparse node-jssip node-jsv node-merge node-mime node-nan node-node-uuid node-qs node-request
  node-rtcninja node-sdp-transform node-tunnel-agent node-typedarray-to-buffer node-util node-websocket nodejs perl
  perl-modules-5.22 rename rlwrap
0 upgraded, 62 newly installed, 0 to remove and 6 not upgraded.
Need to get 17.2 MB of archives.
After this operation, 91.0 MB of additional disk space will be used.
Get:1 http://archive.ubuntu.com/ubuntu xenial/main amd64 libatm1 amd64 1:2.5.1-1.5 [24.2 kB]
Get:2 https://deb.nodesource.com/node_4.x xenial/main amd64 nodejs amd64 4.8.1-1nodesource1~xenial1 [8530 kB]
Get:3 http://archive.ubuntu.com/ubuntu xenial/main amd64 libmnl0 amd64 1.0.3-5 [12.0 kB]
Get:4 http://archive.ubuntu.com/ubuntu xenial/main amd64 libgdbm3 amd64 1.8.3-13.1 [16.9 kB]
Get:5 http://archive.ubuntu.com/ubuntu xenial/main amd64 perl-modules-5.22 all 5.22.1-9 [2641 kB]
Get:6 http://archive.ubuntu.com/ubuntu xenial/main amd64 libperl5.22 amd64 5.22.1-9 [3371 kB]
Get:7 http://archive.ubuntu.com/ubuntu xenial/main amd64 perl amd64 5.22.1-9 [237 kB]
Get:8 http://archive.ubuntu.com/ubuntu xenial/main amd64 iproute2 amd64 4.3.0-1ubuntu3 [522 kB]
Get:9 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 ifupdown amd64 0.8.10ubuntu1.2 [54.9 kB]
Get:10 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libisc-export160 amd64 1:9.10.3.dfsg.P4-8ubuntu1.5 [153 kB]
Get:11 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libdns-export162 amd64 1:9.10.3.dfsg.P4-8ubuntu1.5 [665 kB]
Get:12 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 isc-dhcp-client amd64 4.3.3-5ubuntu12.6 [223 kB]
Get:13 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 isc-dhcp-common amd64 4.3.3-5ubuntu12.6 [105 kB]
Get:14 http://archive.ubuntu.com/ubuntu xenial/main amd64 libxtables11 amd64 1.6.0-2ubuntu3 [27.2 kB]
Get:15 http://archive.ubuntu.com/ubuntu xenial/main amd64 netbase all 5.3 [12.9 kB]
Get:16 http://archive.ubuntu.com/ubuntu xenial/main amd64 javascript-common all 11 [6066 B]
Get:17 http://archive.ubuntu.com/ubuntu xenial/universe amd64 libjs-bowser all 0.7.3-2 [6476 B]
Get:18 http://archive.ubuntu.com/ubuntu xenial/universe amd64 libjs-events all 1.0.2-2 [5532 B]
Get:19 http://archive.ubuntu.com/ubuntu xenial/universe amd64 libjs-is-typedarray all 1.0.0-2 [2934 B]
Get:20 http://archive.ubuntu.com/ubuntu xenial/universe amd64 libjs-websocket all 1.0.22-2 [19.1 kB]
Get:21 http://archive.ubuntu.com/ubuntu xenial/universe amd64 libjs-merge all 1.2.0-2 [3878 B]
Get:22 http://archive.ubuntu.com/ubuntu xenial/universe amd64 libjs-rtcninja all 0.6.2-2 [12.2 kB]
Get:23 http://archive.ubuntu.com/ubuntu xenial/universe amd64 libjs-inherits all 2.0.1-3 [2794 B]
Get:24 http://archive.ubuntu.com/ubuntu xenial/universe amd64 rlwrap amd64 0.41-1build1 [74.9 kB]
Get:25 http://archive.ubuntu.com/ubuntu xenial/universe amd64 node-inherits all 2.0.1-3 [3060 B]
Get:26 http://archive.ubuntu.com/ubuntu xenial/universe amd64 libjs-util all 0.10.3-2 [9342 B]
Get:27 http://archive.ubuntu.com/ubuntu xenial/universe amd64 libjs-sdp-transform all 1.4.0-2 [10.6 kB]
Get:28 http://archive.ubuntu.com/ubuntu xenial/universe amd64 libjs-jssip all 0.6.34-5 [63.2 kB]
Get:29 http://archive.ubuntu.com/ubuntu xenial/universe amd64 libjs-node-uuid all 1.4.0-1 [11.1 kB]
Get:30 http://archive.ubuntu.com/ubuntu xenial/universe amd64 libjs-typedarray-to-buffer all 3.0.3-3 [3986 B]
Get:31 http://archive.ubuntu.com/ubuntu xenial/universe amd64 node-async all 0.8.0-1 [22.2 kB]
Get:32 http://archive.ubuntu.com/ubuntu xenial/universe amd64 node-bowser all 0.7.3-2 [2200 B]
Get:33 http://archive.ubuntu.com/ubuntu xenial/universe amd64 node-events all 1.0.2-2 [2290 B]
Get:34 http://archive.ubuntu.com/ubuntu xenial/universe amd64 node-is-typedarray all 1.0.0-2 [2216 B]
Get:35 http://archive.ubuntu.com/ubuntu xenial/universe amd64 node-jsesc all 0.5.0-1 [11.3 kB]
Get:36 http://archive.ubuntu.com/ubuntu xenial/universe amd64 node-nan all 2.2.0-1 [37.1 kB]
Get:37 http://archive.ubuntu.com/ubuntu xenial/universe amd64 node-typedarray-to-buffer all 3.0.3-3 [2374 B]
Get:38 http://archive.ubuntu.com/ubuntu xenial/universe amd64 node-debug all 2.1.0+dfsg-2 [12.3 kB]
Get:39 http://archive.ubuntu.com/ubuntu xenial/universe amd64 node-websocket amd64 1.0.22-2 [33.5 kB]
Get:40 http://archive.ubuntu.com/ubuntu xenial/universe amd64 node-merge all 1.2.0-2 [2300 B]
Get:41 http://archive.ubuntu.com/ubuntu xenial/universe amd64 node-rtcninja all 0.6.2-2 [2564 B]
Get:42 http://archive.ubuntu.com/ubuntu xenial/universe amd64 node-util all 0.10.3-2 [2294 B]
Get:43 http://archive.ubuntu.com/ubuntu xenial/universe amd64 node-sdp-transform all 1.4.0-2 [2460 B]
Get:44 http://archive.ubuntu.com/ubuntu xenial/universe amd64 node-jssip all 0.6.34-5 [2706 B]
Get:45 http://archive.ubuntu.com/ubuntu xenial/universe amd64 node-node-uuid all 1.4.0-1 [2530 B]
Get:46 http://archive.ubuntu.com/ubuntu xenial/main amd64 rename all 0.20-4 [12.0 kB]
Get:47 http://archive.ubuntu.com/ubuntu xenial/universe amd64 node-delayed-stream all 0.0.5-1 [4750 B]
Get:48 http://archive.ubuntu.com/ubuntu xenial/universe amd64 node-combined-stream all 0.0.5-1 [4958 B]
Get:49 http://archive.ubuntu.com/ubuntu xenial/universe amd64 node-contextify amd64 0.1.6-1 [13.9 kB]
Get:50 http://archive.ubuntu.com/ubuntu xenial/universe amd64 node-cookie-jar all 0.3.1-1 [3746 B]
Get:51 http://archive.ubuntu.com/ubuntu xenial/universe amd64 node-cssom all 0.3.0-1 [11.9 kB]
Get:52 http://archive.ubuntu.com/ubuntu xenial/universe amd64 node-forever-agent all 0.5.1-1 [3194 B]
Get:53 http://archive.ubuntu.com/ubuntu xenial/universe amd64 node-mime all 1.3.4-1 [11.9 kB]
Get:54 http://archive.ubuntu.com/ubuntu xenial/universe amd64 node-form-data all 0.1.0-1 [6412 B]
Get:55 http://archive.ubuntu.com/ubuntu xenial/universe amd64 node-htmlparser all 1.7.5+ds1-1 [11.9 kB]
Get:56 http://archive.ubuntu.com/ubuntu xenial/universe amd64 node-tunnel-agent all 0.3.1-1 [4018 B]
Get:57 http://archive.ubuntu.com/ubuntu xenial/universe amd64 node-json-stringify-safe all 5.0.0-1 [3544 B]
Get:58 http://archive.ubuntu.com/ubuntu xenial/universe amd64 node-qs all 2.2.4-1 [7574 B]
Get:59 http://archive.ubuntu.com/ubuntu xenial/universe amd64 node-request all 2.26.1-1 [14.5 kB]
Get:60 http://archive.ubuntu.com/ubuntu xenial/universe amd64 node-jsdom all 0.8.10+dfsg1-1 [98.9 kB]
Get:61 http://archive.ubuntu.com/ubuntu xenial/universe amd64 node-jsonparse all 1.0.0-1 [6238 B]
Get:62 http://archive.ubuntu.com/ubuntu xenial/universe amd64 node-jsv all 4.0.0+ds1-1 [37.2 kB]
Fetched 17.2 MB in 19s (868 kB/s)
debconf: delaying package configuration, since apt-utils is not installed
Selecting previously unselected package libatm1:amd64.
(Reading database ... 8817 files and directories currently installed.)
Preparing to unpack .../libatm1_1%3a2.5.1-1.5_amd64.deb ...
Unpacking libatm1:amd64 (1:2.5.1-1.5) ...
Selecting previously unselected package libmnl0:amd64.
Preparing to unpack .../libmnl0_1.0.3-5_amd64.deb ...
Unpacking libmnl0:amd64 (1.0.3-5) ...
Selecting previously unselected package libgdbm3:amd64.
Preparing to unpack .../libgdbm3_1.8.3-13.1_amd64.deb ...
Unpacking libgdbm3:amd64 (1.8.3-13.1) ...
Selecting previously unselected package perl-modules-5.22.
Preparing to unpack .../perl-modules-5.22_5.22.1-9_all.deb ...
Unpacking perl-modules-5.22 (5.22.1-9) ...
Selecting previously unselected package libperl5.22:amd64.
Preparing to unpack .../libperl5.22_5.22.1-9_amd64.deb ...
Unpacking libperl5.22:amd64 (5.22.1-9) ...
Selecting previously unselected package perl.
Preparing to unpack .../perl_5.22.1-9_amd64.deb ...
Unpacking perl (5.22.1-9) ...
Selecting previously unselected package iproute2.
Preparing to unpack .../iproute2_4.3.0-1ubuntu3_amd64.deb ...
Unpacking iproute2 (4.3.0-1ubuntu3) ...
Selecting previously unselected package ifupdown.
Preparing to unpack .../ifupdown_0.8.10ubuntu1.2_amd64.deb ...
Unpacking ifupdown (0.8.10ubuntu1.2) ...
Selecting previously unselected package libisc-export160.
Preparing to unpack .../libisc-export160_1%3a9.10.3.dfsg.P4-8ubuntu1.5_amd64.deb ...
Unpacking libisc-export160 (1:9.10.3.dfsg.P4-8ubuntu1.5) ...
Selecting previously unselected package libdns-export162.
Preparing to unpack .../libdns-export162_1%3a9.10.3.dfsg.P4-8ubuntu1.5_amd64.deb ...
Unpacking libdns-export162 (1:9.10.3.dfsg.P4-8ubuntu1.5) ...
Selecting previously unselected package isc-dhcp-client.
Preparing to unpack .../isc-dhcp-client_4.3.3-5ubuntu12.6_amd64.deb ...
Unpacking isc-dhcp-client (4.3.3-5ubuntu12.6) ...
Selecting previously unselected package isc-dhcp-common.
Preparing to unpack .../isc-dhcp-common_4.3.3-5ubuntu12.6_amd64.deb ...
Unpacking isc-dhcp-common (4.3.3-5ubuntu12.6) ...
Selecting previously unselected package libxtables11:amd64.
Preparing to unpack .../libxtables11_1.6.0-2ubuntu3_amd64.deb ...
Unpacking libxtables11:amd64 (1.6.0-2ubuntu3) ...
Selecting previously unselected package netbase.
Preparing to unpack .../archives/netbase_5.3_all.deb ...
Unpacking netbase (5.3) ...
Selecting previously unselected package javascript-common.
Preparing to unpack .../javascript-common_11_all.deb ...
Unpacking javascript-common (11) ...
Selecting previously unselected package libjs-bowser.
Preparing to unpack .../libjs-bowser_0.7.3-2_all.deb ...
Unpacking libjs-bowser (0.7.3-2) ...
Selecting previously unselected package libjs-events.
Preparing to unpack .../libjs-events_1.0.2-2_all.deb ...
Unpacking libjs-events (1.0.2-2) ...
Selecting previously unselected package libjs-is-typedarray.
Preparing to unpack .../libjs-is-typedarray_1.0.0-2_all.deb ...
Unpacking libjs-is-typedarray (1.0.0-2) ...
Selecting previously unselected package libjs-websocket.
Preparing to unpack .../libjs-websocket_1.0.22-2_all.deb ...
Unpacking libjs-websocket (1.0.22-2) ...
Selecting previously unselected package libjs-merge.
Preparing to unpack .../libjs-merge_1.2.0-2_all.deb ...
Unpacking libjs-merge (1.2.0-2) ...
Selecting previously unselected package libjs-rtcninja.
Preparing to unpack .../libjs-rtcninja_0.6.2-2_all.deb ...
Unpacking libjs-rtcninja (0.6.2-2) ...
Selecting previously unselected package libjs-inherits.
Preparing to unpack .../libjs-inherits_2.0.1-3_all.deb ...
Unpacking libjs-inherits (2.0.1-3) ...
Selecting previously unselected package rlwrap.
Preparing to unpack .../rlwrap_0.41-1build1_amd64.deb ...
Unpacking rlwrap (0.41-1build1) ...
Selecting previously unselected package nodejs.
Preparing to unpack .../nodejs_4.8.1-1nodesource1~xenial1_amd64.deb ...
Unpacking nodejs (4.8.1-1nodesource1~xenial1) ...
Selecting previously unselected package node-inherits.
Preparing to unpack .../node-inherits_2.0.1-3_all.deb ...
Unpacking node-inherits (2.0.1-3) ...
Selecting previously unselected package libjs-util.
Preparing to unpack .../libjs-util_0.10.3-2_all.deb ...
Unpacking libjs-util (0.10.3-2) ...
Selecting previously unselected package libjs-sdp-transform.
Preparing to unpack .../libjs-sdp-transform_1.4.0-2_all.deb ...
Unpacking libjs-sdp-transform (1.4.0-2) ...
Selecting previously unselected package libjs-jssip.
Preparing to unpack .../libjs-jssip_0.6.34-5_all.deb ...
Unpacking libjs-jssip (0.6.34-5) ...
Selecting previously unselected package libjs-node-uuid.
Preparing to unpack .../libjs-node-uuid_1.4.0-1_all.deb ...
Unpacking libjs-node-uuid (1.4.0-1) ...
Selecting previously unselected package libjs-typedarray-to-buffer.
Preparing to unpack .../libjs-typedarray-to-buffer_3.0.3-3_all.deb ...
Unpacking libjs-typedarray-to-buffer (3.0.3-3) ...
Selecting previously unselected package node-async.
Preparing to unpack .../node-async_0.8.0-1_all.deb ...
Unpacking node-async (0.8.0-1) ...
Selecting previously unselected package node-bowser.
Preparing to unpack .../node-bowser_0.7.3-2_all.deb ...
Unpacking node-bowser (0.7.3-2) ...
Selecting previously unselected package node-events.
Preparing to unpack .../node-events_1.0.2-2_all.deb ...
Unpacking node-events (1.0.2-2) ...
Selecting previously unselected package node-is-typedarray.
Preparing to unpack .../node-is-typedarray_1.0.0-2_all.deb ...
Unpacking node-is-typedarray (1.0.0-2) ...
Selecting previously unselected package node-jsesc.
Preparing to unpack .../node-jsesc_0.5.0-1_all.deb ...
Unpacking node-jsesc (0.5.0-1) ...
Selecting previously unselected package node-nan.
Preparing to unpack .../node-nan_2.2.0-1_all.deb ...
Unpacking node-nan (2.2.0-1) ...
Selecting previously unselected package node-typedarray-to-buffer.
Preparing to unpack .../node-typedarray-to-buffer_3.0.3-3_all.deb ...
Unpacking node-typedarray-to-buffer (3.0.3-3) ...
Selecting previously unselected package node-debug.
Preparing to unpack .../node-debug_2.1.0+dfsg-2_all.deb ...
Unpacking node-debug (2.1.0+dfsg-2) ...
Selecting previously unselected package node-websocket.
Preparing to unpack .../node-websocket_1.0.22-2_amd64.deb ...
Unpacking node-websocket (1.0.22-2) ...
Selecting previously unselected package node-merge.
Preparing to unpack .../node-merge_1.2.0-2_all.deb ...
Unpacking node-merge (1.2.0-2) ...
Selecting previously unselected package node-rtcninja.
Preparing to unpack .../node-rtcninja_0.6.2-2_all.deb ...
Unpacking node-rtcninja (0.6.2-2) ...
Selecting previously unselected package node-util.
Preparing to unpack .../node-util_0.10.3-2_all.deb ...
Unpacking node-util (0.10.3-2) ...
Selecting previously unselected package node-sdp-transform.
Preparing to unpack .../node-sdp-transform_1.4.0-2_all.deb ...
Unpacking node-sdp-transform (1.4.0-2) ...
Selecting previously unselected package node-jssip.
Preparing to unpack .../node-jssip_0.6.34-5_all.deb ...
Unpacking node-jssip (0.6.34-5) ...
Selecting previously unselected package node-node-uuid.
Preparing to unpack .../node-node-uuid_1.4.0-1_all.deb ...
Unpacking node-node-uuid (1.4.0-1) ...
Selecting previously unselected package rename.
Preparing to unpack .../archives/rename_0.20-4_all.deb ...
Unpacking rename (0.20-4) ...
Selecting previously unselected package node-delayed-stream.
Preparing to unpack .../node-delayed-stream_0.0.5-1_all.deb ...
Unpacking node-delayed-stream (0.0.5-1) ...
Selecting previously unselected package node-combined-stream.
Preparing to unpack .../node-combined-stream_0.0.5-1_all.deb ...
Unpacking node-combined-stream (0.0.5-1) ...
Selecting previously unselected package node-contextify.
Preparing to unpack .../node-contextify_0.1.6-1_amd64.deb ...
Unpacking node-contextify (0.1.6-1) ...
Selecting previously unselected package node-cookie-jar.
Preparing to unpack .../node-cookie-jar_0.3.1-1_all.deb ...
Unpacking node-cookie-jar (0.3.1-1) ...
Selecting previously unselected package node-cssom.
Preparing to unpack .../node-cssom_0.3.0-1_all.deb ...
Unpacking node-cssom (0.3.0-1) ...
Selecting previously unselected package node-forever-agent.
Preparing to unpack .../node-forever-agent_0.5.1-1_all.deb ...
Unpacking node-forever-agent (0.5.1-1) ...
Selecting previously unselected package node-mime.
Preparing to unpack .../node-mime_1.3.4-1_all.deb ...
Unpacking node-mime (1.3.4-1) ...
Selecting previously unselected package node-form-data.
Preparing to unpack .../node-form-data_0.1.0-1_all.deb ...
Unpacking node-form-data (0.1.0-1) ...
Selecting previously unselected package node-htmlparser.
Preparing to unpack .../node-htmlparser_1.7.5+ds1-1_all.deb ...
Unpacking node-htmlparser (1.7.5+ds1-1) ...
Selecting previously unselected package node-tunnel-agent.
Preparing to unpack .../node-tunnel-agent_0.3.1-1_all.deb ...
Unpacking node-tunnel-agent (0.3.1-1) ...
Selecting previously unselected package node-json-stringify-safe.
Preparing to unpack .../node-json-stringify-safe_5.0.0-1_all.deb ...
Unpacking node-json-stringify-safe (5.0.0-1) ...
Selecting previously unselected package node-qs.
Preparing to unpack .../node-qs_2.2.4-1_all.deb ...
Unpacking node-qs (2.2.4-1) ...
Selecting previously unselected package node-request.
Preparing to unpack .../node-request_2.26.1-1_all.deb ...
Unpacking node-request (2.26.1-1) ...
Selecting previously unselected package node-jsdom.
Preparing to unpack .../node-jsdom_0.8.10+dfsg1-1_all.deb ...
Unpacking node-jsdom (0.8.10+dfsg1-1) ...
Selecting previously unselected package node-jsonparse.
Preparing to unpack .../node-jsonparse_1.0.0-1_all.deb ...
Unpacking node-jsonparse (1.0.0-1) ...
Selecting previously unselected package node-jsv.
Preparing to unpack .../node-jsv_4.0.0+ds1-1_all.deb ...
Unpacking node-jsv (4.0.0+ds1-1) ...
Processing triggers for systemd (229-4ubuntu16) ...
Processing triggers for libc-bin (2.23-0ubuntu5) ...
Setting up libatm1:amd64 (1:2.5.1-1.5) ...
Setting up libmnl0:amd64 (1.0.3-5) ...
Setting up libgdbm3:amd64 (1.8.3-13.1) ...
Setting up perl-modules-5.22 (5.22.1-9) ...
Setting up libperl5.22:amd64 (5.22.1-9) ...
Setting up perl (5.22.1-9) ...
update-alternatives: using /usr/bin/prename to provide /usr/bin/rename (rename) in auto mode
Setting up iproute2 (4.3.0-1ubuntu3) ...
Setting up ifupdown (0.8.10ubuntu1.2) ...
Creating /etc/network/interfaces.
Setting up libisc-export160 (1:9.10.3.dfsg.P4-8ubuntu1.5) ...
Setting up libdns-export162 (1:9.10.3.dfsg.P4-8ubuntu1.5) ...
Setting up isc-dhcp-client (4.3.3-5ubuntu12.6) ...
Setting up isc-dhcp-common (4.3.3-5ubuntu12.6) ...
Setting up libxtables11:amd64 (1.6.0-2ubuntu3) ...
Setting up netbase (5.3) ...
Setting up javascript-common (11) ...
Setting up libjs-bowser (0.7.3-2) ...
Setting up libjs-events (1.0.2-2) ...
Setting up libjs-is-typedarray (1.0.0-2) ...
Setting up libjs-websocket (1.0.22-2) ...
Setting up libjs-merge (1.2.0-2) ...
Setting up libjs-rtcninja (0.6.2-2) ...
Setting up libjs-inherits (2.0.1-3) ...
Setting up rlwrap (0.41-1build1) ...
update-alternatives: using /usr/bin/rlwrap to provide /usr/bin/readline-editor (readline-editor) in auto mode
Setting up nodejs (4.8.1-1nodesource1~xenial1) ...
Setting up node-inherits (2.0.1-3) ...
Setting up libjs-util (0.10.3-2) ...
Setting up libjs-sdp-transform (1.4.0-2) ...
Setting up libjs-jssip (0.6.34-5) ...
Setting up libjs-node-uuid (1.4.0-1) ...
Setting up libjs-typedarray-to-buffer (3.0.3-3) ...
Setting up node-async (0.8.0-1) ...
Setting up node-bowser (0.7.3-2) ...
Setting up node-events (1.0.2-2) ...
Setting up node-is-typedarray (1.0.0-2) ...
Setting up node-jsesc (0.5.0-1) ...
Setting up node-nan (2.2.0-1) ...
Setting up node-typedarray-to-buffer (3.0.3-3) ...
Setting up node-debug (2.1.0+dfsg-2) ...
Setting up node-websocket (1.0.22-2) ...
Setting up node-merge (1.2.0-2) ...
Setting up node-rtcninja (0.6.2-2) ...
Setting up node-util (0.10.3-2) ...
Setting up node-sdp-transform (1.4.0-2) ...
Setting up node-jssip (0.6.34-5) ...
Setting up node-node-uuid (1.4.0-1) ...
Setting up rename (0.20-4) ...
update-alternatives: using /usr/bin/file-rename to provide /usr/bin/rename (rename) in auto mode
Setting up node-delayed-stream (0.0.5-1) ...
Setting up node-combined-stream (0.0.5-1) ...
Setting up node-contextify (0.1.6-1) ...
Setting up node-cookie-jar (0.3.1-1) ...
Setting up node-cssom (0.3.0-1) ...
Setting up node-forever-agent (0.5.1-1) ...
Setting up node-mime (1.3.4-1) ...
Setting up node-form-data (0.1.0-1) ...
Setting up node-htmlparser (1.7.5+ds1-1) ...
Setting up node-tunnel-agent (0.3.1-1) ...
Setting up node-json-stringify-safe (5.0.0-1) ...
Setting up node-qs (2.2.4-1) ...
Setting up node-request (2.26.1-1) ...
Setting up node-jsdom (0.8.10+dfsg1-1) ...
Setting up node-jsonparse (1.0.0-1) ...
Setting up node-jsv (4.0.0+ds1-1) ...
Processing triggers for libc-bin (2.23-0ubuntu5) ...
Processing triggers for systemd (229-4ubuntu16) ...
```

CTRL+Dでコンテナを終了し、コンテナのプロセスを確認します

```bash:コマンド
$ docker ps -a
CONTAINER ID        IMAGE                            COMMAND                  CREATED             STATUS                         PORTS               NAMES
1d1da0a0d8f6        ubuntu                           "/bin/bash"              49 minutes ago      Exited (127) 4 seconds ago                         angry_noyce
1acd155a8bd8        ubuntu:15.10                     "cat /etc/lsb-release"   51 minutes ago      Exited (0) 51 minutes ago                          priceless_hypatia
3ee142a25a16        ubuntu                           "cat /etc/lsb-release"   57 minutes ago      Exited (0) 57 minutes ago                          zen_hoover
37190b0b585a        hello-world                      "/hello"                 About an hour ago   Exited (0) About an hour ago                       gifted_newton
47ed1ae7ecd4        hello-world                      "/hello"                 4 months ago        Exited (0) 4 months ago                            kickass_meitner
5c87d3fca1c9        b.gcr.io/tensorflow/tensorflow   "/run_jupyter.sh"        4 months ago        Exited (0) 4 months ago                            sad_jang
52e9083b691e        nginx                            "nginx -g 'daemon ..."   6 months ago        Exited (0) 6 months ago                            webserver
3cfc48775c51        hello-world                      "/hello"                 6 months ago        Exited (0) 6 months ago                            distracted_perlman
01a1dcd7b8b5        sadayoshitada1989/mybusybox      "sh"                     10 months ago       Exited (0) 10 months ago                           romantic_heyrovsky
3f473e4a3985        sadayoshitada1989/mybusybox      "cat /hello.txt"         10 months ago       Exited (0) 10 months ago                           pensive_blackwell
```

### 3.コンテナからイメージを作成する
イメージを作成するには、`docker commit コンテナID Dockerイメージ名`のコマンドを実行します。
`docker images`で作成したイメージを確認できます。

```bash:コマンド
$ docker commit 1d1da0a0d8f6 ubuntu-nodejs-01
sha256:d0d26b70abad24fc7b93b5d47a12af711e682e7b41e93e9ecd10577d272eee24
$ docker images
REPOSITORY                       TAG                 IMAGE ID            CREATED             SIZE
ubuntu-nodejs-01                 latest              d0d26b70abad        19 seconds ago      304 MB
```

Node.jsがインストールされているかを確認してみます。

```bash:コマンド
$ docker run ubuntu-nodejs-01 node --version
v4.8.1
```

## 6.4 DockerfileからのDockerイメージ作成
Dockerでは、DocekrfileにDockerイメージの構築手順を記述し、喜寿した手順からDockerイメージをビルドすることができます。

### 1.Dockerfileの作成
Dockerfileを作ります。AWSのUserdataのようなものですかね。

```bash:Dockerfile
$ vi Dockerfile
FROM ubuntu

RUN apt-get update
RUN apt-get install -y curl
RUN curl -sL https://deb.nodesource.com/setup_4.x | bash -
RUN apt-get install -y nodejs
```
FROMコマンドで、ベースのイメージを指定し、RUNコマンドで、インストール手順を指定します。

### 2.Dockerイメージのビルド
Dockerイメージ作成します。

```bash:コマンド
$ docker build -t ubuntu-nodejs-2 .
Sending build context to Docker daemon 2.048 kB
Step 1/5 : FROM ubuntu
 ---> 0ef2e08ed3fa
Step 2/5 : RUN apt-get update
 ---> Running in 5b70427f9ae9
Get:1 http://archive.ubuntu.com/ubuntu xenial InRelease [247 kB]
~中略~
Step 3/5 : RUN apt-get install -y curl
 ---> Running in 81b435f80fd2
~中略~
Step 4/5 : RUN curl -sL https://deb.nodesource.com/setup_4.x | bash -
 ---> Running in 5385ab868792
~中略~
Step 5/5 : RUN apt-get install -y nodejs
 ---> Running in d30387fe3473
~中略~
 ---> 2e691ac30aa1
Removing intermediate container d30387fe3473
Successfully built 2e691ac30aa1
```
RUNコマンド１つにつき、１つのファイルシステムの層が作られます。ただ、ファイルシステムの上限は、１２７を超えることができません。

作成したイメージの確認します。

```bash:コマンド
$ docker images
REPOSITORY                       TAG                 IMAGE ID            CREATED             SIZE
ubuntu-nodejs-2                  latest              2e691ac30aa1        25 minutes ago      303 MB
```

## 6.5 アプリのDockerイメージ作成
作成したDockerイメージを元に、アプリケーションのDockerイメージを作ります。

### 1.アプリケーションの作成
アプリケーションの本体となる、app.jsを作ります。

```bash:コマンド
$ vi app.js
var express = require('express');
var app = express();

app.get('/', function (req,res) {
  res.send('Hello World');
});

app.listen(8080);
console.log('Running on port 8080');
```

次にアプリケーションの情報を記述したpackage.jsonを作成します。

```bash:コマンド
vi package.json
{
 "name": "docker_web_app",
 "version": "1.0.0" ,
 "dependencies" : {
    "express": "^4.13.3"
 }
}
```

### 2. Dockerfileの作成

```bash:コマンド
FROM ubuntu-nodejs-2
RUN mkdir /app
ADD app.js /app
ADD package.json /app

WORKDIR /app
RUN npm install

EXPOSE 8080
CMD [ "node", "app.js" ]
```
* ADDコマンドは、ローカルにある指定ファイルをDockerイメージの指定したディレクトリに追加できます。
* WORKDIRコマンドは、作業ディレクトリを指定できます。
* EXPOSEコマンドは、アプリケーションが待ち受けるポート番号を記述します。
* CMDコマンドは、コンテナ実行時にデフォルトで実行するコマンドを指定します。

### 3. Dockerfileのビルド
Dockerイメージ(ubuntu-node-app)を作ります。

```bash:コマンド
$ docker build -t ubuntu-node-app .
Sending build context to Docker daemon 4.096 kB
Step 1/8 : FROM ubuntu-nodejs-2
 ---> 2e691ac30aa1
Step 2/8 : RUN mkdir /app
 ---> Running in 66b191476d5a
 ---> 4fa96fa8dd0f
Removing intermediate container 66b191476d5a
Step 3/8 : ADD app.js /app
 ---> d1dcf574bf31
Removing intermediate container 39be7848ee07
Step 4/8 : ADD package.json /app
 ---> 0f977220ca9e
Removing intermediate container 0da1965edf4a
Step 5/8 : WORKDIR /app
 ---> 6b2eb83ebefb
Removing intermediate container 48ad6e66c994
Step 6/8 : RUN npm install
 ---> Running in 4aa81192be0a
npm WARN package.json docker_web_app@1.0.0 No description
npm WARN package.json docker_web_app@1.0.0 No repository field.
npm WARN package.json docker_web_app@1.0.0 No README data
npm WARN package.json docker_web_app@1.0.0 No license field.
express@4.15.2 node_modules/express
├── setprototypeof@1.0.3
├── escape-html@1.0.3
├── array-flatten@1.1.1
├── utils-merge@1.0.0
├── cookie-signature@1.0.6
├── methods@1.1.2
├── encodeurl@1.0.1
├── merge-descriptors@1.0.1
├── content-type@1.0.2
├── content-disposition@0.5.2
├── range-parser@1.2.0
├── parseurl@1.3.1
├── fresh@0.5.0
├── etag@1.8.0
├── cookie@0.3.1
├── vary@1.1.1
├── serve-static@1.12.1
├── path-to-regexp@0.1.7
├── statuses@1.3.1
├── depd@1.1.0
├── qs@6.4.0
├── on-finished@2.3.0 (ee-first@1.1.1)
├── debug@2.6.1 (ms@0.7.2)
├── proxy-addr@1.1.4 (forwarded@0.1.0, ipaddr.js@1.3.0)
├── send@0.15.1 (destroy@1.0.4, ms@0.7.2, mime@1.3.4, http-errors@1.6.1)
├── finalhandler@1.0.1 (unpipe@1.0.0, debug@2.6.3)
├── type-is@1.6.14 (media-typer@0.3.0, mime-types@2.1.15)
└── accepts@1.3.3 (negotiator@0.6.1, mime-types@2.1.15)
 ---> e2a431b69c9a
Removing intermediate container 4aa81192be0a
Step 7/8 : EXPOSE 8080
 ---> Running in 99e3dadf0251
 ---> 5bff094dd0af
Removing intermediate container 99e3dadf0251
Step 8/8 : CMD node app.js
 ---> Running in 55c8a99e6e74
 ---> ef060be7e580
Removing intermediate container 55c8a99e6e74
Successfully built ef060be7e580
```

作成したDockerイメージを確認します。

```bash:コマンド
$ docker images
REPOSITORY                       TAG                 IMAGE ID            CREATED             SIZE
ubuntu-node-app                  latest              ef060be7e580        6 minutes ago       307 MB
```
アプリケーションを実行し、ブラウザでアクセスすると、「Hello,World」が表示されました。

```bash:コマンド
$ docker run -p 8080:8080 ubuntu-node-app
Running on port 8080
```
![capture01.png](https://qiita-image-store.s3.amazonaws.com/0/59666/0b5035ce-c9f8-5a50-8049-85f295c17b64.png)

## 6.6 DockerイメージをDocker Hubへアップロード
作成したDockerイメージは、Docker HubなどのDockerレジストリにアップロードし、保存します。

### 1. Dokcer Hubでレポジトリ作成
Dockerイメージをアップロードするために、Docker Hubアカウントを作成しておく必要があります。
https://hub.docker.com/

### 2. Docker Hubにアップロード
Docker Hubの表記に合わせてDockerイメージの名前を変更します。

```bash:コマンド
$ docker tag ubuntu-node-app sadayoshitada1989/ubuntu-node-app
(何も表示されない)
$ docker images
REPOSITORY                          TAG                 IMAGE ID            CREATED             SIZE
sadayoshitada1989/ubuntu-node-app   latest              483930ed0253        8 minutes ago       307 MB
```
Docker Hubにログインし、Dockerイメージをアップロードします。

```bash:コマンド
$ docker login
Login with your Docker ID to push and pull images from Docker Hub. If you don't have a Docker ID, head over to https://hub.docker.com to create one.
Username (sadayoshitada1989):
Password:
Login Succeeded
$ docker push sadayoshitada1989/ubuntu-node-app
The push refers to a repository [docker.io/sadayoshitada1989/ubuntu-node-app]
7132c8312ff3: Pushed
3fa2040079de: Pushed
625cf7c88282: Pushed
e9579f435fdf: Pushed
e88d2bc467c3: Pushed
060b7bee47a3: Pushed
d10b6538a5af: Pushed
3556a6d1f867: Pushed
56827159aa8b: Mounted from library/ubuntu
440e02c3dcde: Mounted from library/ubuntu
29660d0e5bb2: Mounted from library/ubuntu
85782553e37a: Mounted from library/ubuntu
745f5be9952c: Mounted from library/ubuntu
latest: digest: sha256:619584e6929a1435f5ef072e07339cf7c973e79b6a931fc94d291a04ca25640c size: 3035
```
Docker Hubで確認してみます。
![capture02.png](https://qiita-image-store.s3.amazonaws.com/0/59666/7ce93298-9f82-6358-0499-052f1f0cc612.png)
アップロードできてますねー！

# まとめ
今回は、次のことやりました。

* Dokckerイメージを使って、コンテナを展開し、パッケージとアプリのセットアップ
* Dockerイメージの作成
* Dockerfileのビルド
* DockerイメージをDocker Hubにアップロード