Docker

@CentOS6

Reffer: the knowledge of sakura
https://knowledge.sakura.ad.jp/13265/

Install docker
Reffrer:
https://qiita.com/is_mgmt_dept/items/f4a7c64d72c2cba440c2
docker supports centos6 restrictly.

#  tee /etc/yum.repos.d/docker.repo <<- 'EOF'
> [dockerrepo]
> name=Docker Repository
> baseurl=https://yum.dockerproject.org/repo/main/centos/$releasever/
> enabled=1
> gpgcheck=1
> gpgkey=https://yum.dockerproject.org/gpg
> EOF
[dockerrepo]
name=Docker Repository
baseurl=https://yum.dockerproject.org/repo/main/centos/$releasever/
enabled=1
gpgcheck=1
gpgkey=https://yum.dockerproject.org/gpg

# yum install docker-engine
読み込んだプラグイン:fastestmirror
インストール処理の設定をしています
Loading mirror speeds from cached hostfile
 * base: ftp.iij.ad.jp
 * extras: ftp.iij.ad.jp
 * ius: hkg.mirror.rackspace.com
 * updates: ftp.iij.ad.jp
dockerrepo                                                                                             | 2.9 kB     00:00
dockerrepo/primary_db                                                                                  | 3.3 kB     00:00
依存性の解決をしています
--> トランザクションの確認を実行しています。
---> Package docker-engine.x86_64 0:1.7.1-1.el6 will be インストール
--> 依存性の処理をしています: libcgroup のパッケージ: docker-engine-1.7.1-1.el6.x86_64
--> トランザクションの確認を実行しています。
---> Package libcgroup.x86_64 0:0.40.rc1-26.el6 will be インストール
--> 依存性解決を終了しました。

依存性を解決しました

==============================================================================================================================
 パッケージ                     アーキテクチャ          バージョン                          リポジトリー                 容量
==============================================================================================================================
インストールしています:
 docker-engine                  x86_64                  1.7.1-1.el6                         dockerrepo                  4.5 M
依存性関連でのインストールをします。:
 libcgroup                      x86_64                  0.40.rc1-26.el6                     base                        131 k

トランザクションの要約
==============================================================================================================================
インストール         2 パッケージ

総ダウンロード容量: 4.7 M
インストール済み容量: 20 M
これでいいですか? [y/N]y
パッケージをダウンロードしています:
(1/2): docker-engine-1.7.1-1.el6.x86_64.rpm                                                            | 4.5 MB     00:01
(2/2): libcgroup-0.40.rc1-26.el6.x86_64.rpm                                                            | 131 kB     00:00
------------------------------------------------------------------------------------------------------------------------------
合計                                                                                          279 kB/s | 4.7 MB     00:17
warning: rpmts_HdrFromFdno: Header V4 RSA/SHA1 Signature, key ID 2c52609d: NOKEY
Retrieving key from https://yum.dockerproject.org/gpg
Importing GPG key 0x2C52609D:
 Userid: "Docker Release Tool (releasedocker) <docker@docker.com>"
 From  : https://yum.dockerproject.org/gpg
これでいいですか? [y/N]y
rpm_check_debug を実行しています
トランザクションのテストを実行しています
トランザクションのテストを成功しました
トランザクションを実行しています
  インストールしています  : libcgroup-0.40.rc1-26.el6.x86_64                                                              1/2
  インストールしています  : docker-engine-1.7.1-1.el6.x86_64                                                              2/2
  Verifying               : libcgroup-0.40.rc1-26.el6.x86_64                                                              1/2
  Verifying               : docker-engine-1.7.1-1.el6.x86_64                                                              2/2

インストール:
  docker-engine.x86_64 0:1.7.1-1.el6

依存性関連をインストールしました:
  libcgroup.x86_64 0:0.40.rc1-26.el6

完了しました!

Start docker.

# service docker start
Starting cgconfig service:                                 [  OK  ]
Starting docker:                                           [  OK  ]

Install Docker Compose 1.5.2
Under 1.5.2 is only supported on CentOS6.
We need to use version 1 file format for docker-compose.yml

# sh -c "curl -L https://github.com/docker/compose/releases/download/1.5.2/docker-compose-`uname -s`-`uname -m` > /usr/local/b
in/docker-compose"
chmod +x /usr/local/bin/docker-compose  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 7739k  100 7739k    0     0  62114      0  0:02:07  0:02:07 --:--:-- 48506
#
# chmod +x /usr/local/bin/docker-compose

Run nginx container.

# docker pull nginx
latest: Pulling from nginx

3a7eb8efaa63: Pull complete
7fa957bec75e: Pull complete
a5763e208b78: Pull complete
f49678be66d4: Pull complete
0ebadf370b67: Pull complete
f1fdf81390d2: Pull complete
e4751793f6ea: Pull complete
3a6346c78d6a: Pull complete
5351bda27ea6: Pull complete
e37dd9b27b4f: Pull complete
Digest: sha256:1eaf056ce2e2cc81ee3689cb72e06edc17f57e3c45c0d8d
0f79d9cc21ea5ce5e
Status: Downloaded newer image for nginx:latest

list

# docker images
REPOSITORY          TAG                 IMAGE ID            CR
EATED             VIRTUAL SIZE
nginx               latest              e37dd9b27b4f        2
weeks ago         109 MB

run

# docker run -d --name nginx-container -p 80:80 nginx
2983e4e3ea2687a2be4a79c8e412cc21b2cb872f7a9ed5a00508210050d2fb
7a

status

# docker ps -a
CONTAINER ID        IMAGE               COMMAND
 CREATED             STATUS              PORTS
NAMES
2983e4e3ea26        nginx               "nginx -g 'daemon of
 31 seconds ago      Up 29 seconds       0.0.0.0:80->80/tcp
nginx-container
# netstat -an | grep 80
tcp        0      0 :::80                       :::*
              LISTEN

Access by browser on PC or curl.

# curl localhost
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>
    body {
        width: 35em;
        margin: 0 auto;
        font-family: Tahoma, Verdana, Arial, sans-serif;
    }
</style>
</head>
<body>
<h1>Welcome to nginx!</h1>
<p>If you see this page, the nginx web server is successfully
installed and
working. Further configuration is required.</p>

<p>For online documentation and support please refer to
<a href="http://nginx.org/">nginx.org</a>.<br/>
Commercial support is available at
<a href="http://nginx.com/">nginx.com</a>.</p>

<p><em>Thank you for using nginx.</em></p>
</body>
</html>