ときどきAnsible日記

主にITインフラ基盤の自動化に関する事を書いているブログです

DockerのWindows対応について

お疲れ様です。伊藤です。

WindowsServer2016でDockerの対応がされた、と聞いていたんですが自分自身認識が間違っていたので覚書の意味を込めてここに書いておこうと思います。


まず、Dockerというかコンテナの基本ですが、コンテナはハイパーバイザ型の仮想マシンと違い、ホストOSとカーネルを共有しています。したがって、ホストOSと同じOSしか動かない、というのが基本です。(詳細はDockerコンテナの概要 - ときどきAnsible日記をご参照ください)

で、WindowsServer2016のDocker対応ですが、基本的にはDockerはLinuxから生まれたものなので、Linuxコンテナだと思っていました。で、この対応についてもWindowsServer上でHyperVでLinuxを入れてからその上にDockerをインストールするもの、という認識でした。

もちろんこのパターンもあるのですが、実はこれだけではなくDockerはしっかりとWindowsコンテナにも対応していて、それはWindowsServerコンテナと呼ばれるようです。(ちなみに前者はHyperVコンテナと呼称しているようです)

つまりはWindowsでDockerを使う、といった場合WindowsServerコンテナ(コンテナのOSはWindowsServer)、HyperVコンテナ(コンテナのOSはおそらくLinux、おそらくというのはLinux以外も可能ではあるから)の2種類があるということになります。(HyperV以外でもハイパーバイザ型であれば何でも行けますが)


このあたりの認識がすっかり間違ってました。もし以前の記事にDokcerコンテナと言えばLinux限定!みたいなことを書いていて、読んでいる方を混乱させてしまっていたら訂正させていただきます。
詳細は@IT様の記事に乗っております。なぜ昔この記事を見つけられなかったんだろう。。。。
www.atmarkit.co.jp


以上です。お疲れ様でした。

sosreportについて

お疲れ様です。伊藤です。

インフラ構築をしているとき、構築後の設定ファイルなどをまるっと持ってきたい時って多いと思います。大体そんなときはそれ用にスクリプトを作成して設定変更後は必ず流す、というようなことをします。しかし、Redhatの標準機能でsosreportというのがあり、それで全部持ってこれそうなのでちょっと検証してみます。本来であればsosreportはRedhatのサポートに問い合わせするときに送る資材を作成するもの、という認識がありますので本来の使い方からは少々外れます。


まずはsosreportのインストールから
必要なrpmはRHEL7.3で最小インストールだった場合はこの3つでした。

bzip2-1.0.6-13.el7.x86_64.rpm
python-six-1.9.0-2.el7.noarch.rpm
sos-3.3-5.el7_3.noarch.rpm

上から順に入れていけばOK

rpm -i bzip2-1.0.6-13.el7.x86_64.rpm
rpm -i python-six-1.9.0-2.el7.noarch.rpm
rpm -i sos-3.3-5.el7_3.noarch.rpm

で、実行してみます。

# /usr/sbin/sosreport

sosreport (version 3.3)

This command will collect diagnostic and configuration information from
this Red Hat Enterprise Linux system and installed applications.

An archive containing the collected information will be generated in
/var/tmp/sos.w4mD13 and may be provided to a Red Hat support
representative.

Any information provided to Red Hat will be treated in accordance with
the published support policies at:

  https://access.redhat.com/support/

The generated archive may contain data considered sensitive and its
content should be reviewed by the originating organization before being
passed to any third party.

No changes will be made to system configuration.

Press ENTER to continue, or CTRL-C to quit.

Please enter your first initial and last name [RHEL7.3]:
Please enter the case id that you are generating this report for []:

 Setting up archive ...
 Setting up plugins ...
 Running plugins. Please wait ...

  Running 74/74: yum...            
Creating compressed archive...

Your sosreport has been generated and saved in:
  /var/tmp/sosreport-RHEL7.3-20171114102450.tar.xz

The checksum is: 67029a053db3d1e8f8b1ca638ddf7a17

Please send this file to your support representative.

無事終わったっぽい。途中でキー入力を求められる部分はすべて入力無しで進めました。

# ls -la /var/tmp/sosreport-RHEL7.3-20171114102450.tar.xz
-rw------- 1 root root 8066360 11月 14 10:26 /var/tmp/sosreport-RHEL7.3-20171114102450.tar.xz

ファイルもできています。ちなみにこのマシンはRHEL7.3の最小構成インストールを行ったマシンです。
解凍してみます。

# xz -dc /var/tmp/sosreport-RHEL7.3-20171114102450.tar.xz | tar xfv -
sosreport-RHEL7.3-20171114102450/
sosreport-RHEL7.3-20171114102450/sos_commands/
sosreport-RHEL7.3-20171114102450/sos_commands/networking/
sosreport-RHEL7.3-20171114102450/sos_commands/networking/ip_netns
sosreport-RHEL7.3-20171114102450/sos_commands/networking/ip_-o_addr
sosreport-RHEL7.3-20171114102450/sos_commands/networking/iptables_-t_filter_-nvL
sosreport-RHEL7.3-20171114102450/sos_commands/networking/iptables_-t_nat_-nvL
sosreport-RHEL7.3-20171114102450/sos_commands/networking/iptables_-t_mangle_-nvL
sosreport-RHEL7.3-20171114102450/sos_commands/networking/ip6tables_-t_filter_-nvL
sosreport-RHEL7.3-20171114102450/sos_commands/networking/ip6tables_-t_nat_-nvL
sosreport-RHEL7.3-20171114102450/sos_commands/networking/ip6tables_-t_mangle_-nvL
sosreport-RHEL7.3-20171114102450/sos_commands/networking/ip_route_show_table_all
・
・
・

全部乗せようかと思いましたが、あまりの数にあきらめました。
ちなみにファイル数は

# find ./sosreport-RHEL7.3-20171114102450 -type f | wc -l
4450

なかなか多いですね。

配下のディレクトリを見てみます。

# ls -al ./sosreport-RHEL7.3-20171114102450
合計 24
drwx------  14 root root 4096 11月 14 10:26 .
dr-xr-x---.  7 root root 4096 11月 14 10:30 ..
dr-xr-xr-x   3 root root   19  6月 21 17:20 boot
lrwxrwxrwx   1 root root   38 11月 14 10:25 chkconfig -> sos_commands/services/chkconfig_--list
lrwxrwxrwx   1 root root   25 11月 14 10:25 date -> sos_commands/general/date
lrwxrwxrwx   1 root root   27 11月 14 10:25 df -> sos_commands/filesys/df_-al
lrwxrwxrwx   1 root root   31 11月 14 10:25 dmidecode -> sos_commands/hardware/dmidecode
drwxr-xr-x  37 root root 4096 11月 14 10:23 etc
lrwxrwxrwx   1 root root   24 11月 14 10:25 free -> sos_commands/memory/free
lrwxrwxrwx   1 root root   29 11月 14 10:25 hostname -> sos_commands/general/hostname
lrwxrwxrwx   1 root root  130 11月 14 10:25 installed-rpms -> sos_commands/rpm/sh_-c_rpm_--nodigest_-qa_--qf_NAME_-_VERSION_-_RELEASE_._ARCH_INSTALLTIME_date_awk_-F_printf_-59s_s_n_1_2_sort_-f
lrwxrwxrwx   1 root root   34 11月 14 10:25 ip_addr -> sos_commands/networking/ip_-o_addr
lrwxrwxrwx   1 root root   45 11月 14 10:25 java -> sos_commands/java/alternatives_--display_java
lrwxrwxrwx   1 root root   22 11月 14 10:25 last -> sos_commands/last/last
dr-xr-xr-x   7 root root   78  6月 21 17:13 lib
lrwxrwxrwx   1 root root   25 11月 14 10:25 lsmod -> sos_commands/kernel/lsmod
lrwxrwxrwx   1 root root   28 11月 14 10:25 lspci -> sos_commands/pci/lspci_-nnvv
lrwxrwxrwx   1 root root   29 11月 14 10:25 mount -> sos_commands/filesys/mount_-l
drwxr-xr-x   3 root root   20  8月 23 23:31 opt
dr-xr-xr-x  11 root root 4096 11月 14 09:58 proc
lrwxrwxrwx   1 root root   30 11月 14 10:25 ps -> sos_commands/process/ps_auxwww
dr-xr-x---   2 root root   29 11月 14 10:23 root
drwx------  46 root root 4096 11月 14 10:25 sos_commands
drwx------   2 root root   35 11月 14 10:26 sos_logs
drwx------   2 root root   37 11月 14 10:26 sos_reports
dr-xr-xr-x  10 root root  112 11月 14 09:58 sys
lrwxrwxrwx   1 root root   28 11月 14 10:25 uname -> sos_commands/kernel/uname_-a
lrwxrwxrwx   1 root root   27 11月 14 10:25 uptime -> sos_commands/general/uptime
drwxr-xr-x   5 root root   42  6月 21 17:10 usr
drwxr-xr-x   5 root root   41 11月 14 09:58 var
-rw-r--r--   1 root root 1493 11月 14 10:26 version.txt
lrwxrwxrwx   1 root root   62 11月 14 10:25 vgdisplay -> sos_commands/lvm2/vgdisplay_-vv_--config_global_locking_type_0

大体揃ってそうな感じ。

が!重大な問題が2つ!
1つ目はカーネルモジュールを更新してしまうということです。実際にlsmodで前後比較をすると変更されていましたので本番環境などでは注意が必要です。
2つ目はリソースの消費が激しいということです。裏で何かジョブなどが動いている場合は最新の注意を払いましょう。場合によりCPUの優先度などを下げて実行する必要があるかと思います。

こちらの先端技術様の記事を参考にさせていただきました。
第7回「 sosreport ノススメ」 | NTTデータ先端技術株式会社
(ここにほとんど書いてるんですけどね。。。というのは独り言。。)

以上です。お疲れ様でした。