LoginSignup
8
18

More than 5 years have passed since last update.

Docker CE 構築 on CentOS7

Posted at

はじめに

今更ですが、コンテナ関連を勉強していきます。今回は基礎であるDockerを導入してみます。
KubernetesやOpenShiftへもチャレンジしていければと考えています。

Dockerには、Community Edition (CE) と Enterprise Edition (EE)の2つのVersionが存在します。
今回は、Docker CEを CentOS7 にInstallします

DockerCEとDockerEEには、機能差が存在しています。
詳細は以下を参照
https://docs.docker.com/install/

前提条件確認

Repository
Extras Repositoryが有効になっているか確認します。
CentOS7では、Defaultで有効にされていますが、手動で無効にした場合は有効にする必要があります。

[root@sugi-docker-registory dev]# yum repolist
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: ftp.tsukuba.wide.ad.jp
 * extras: ftp.tsukuba.wide.ad.jp
 * updates: ftp.tsukuba.wide.ad.jp
repo id                                                                                            repo name                                                                                             status
base/7/x86_64                                                                                      CentOS-7 - Base                                                                                       9,591
extras/7/x86_64                                                                                    CentOS-7 - Extras                                                                                       388
updates/7/x86_64                                                                                   CentOS-7 - Updates                                                                                    1,929
repolist: 11,908

Install Docker CE

Repositoryの設定

前提パッケージを導入します。

yum install -y yum-utils device-mapper-persistent-data lvm2

StableRepositoryを有効にします。

yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo

確認

[root@sugi-docker-registory dev]# yum repolist
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: ftp.tsukuba.wide.ad.jp
 * extras: ftp.tsukuba.wide.ad.jp
 * updates: ftp.tsukuba.wide.ad.jp
repo id                                                     repo name                                                      status
base/7/x86_64                                               CentOS-7 - Base                                                9,591
docker-ce-stable/x86_64                                     Docker CE Stable - x86_64                                         12
extras/7/x86_64                                             CentOS-7 - Extras                                                388
updates/7/x86_64                                            CentOS-7 - Updates                                             1,929
repolist: 11,920

DockerCEをinstallします

yum install -y docker-ce

依存関係メモ

=================================================================================================================================
 Package                            Arch               Version                                Repository                    Size
=================================================================================================================================
Installing:
 docker-ce                          x86_64             17.12.0.ce-1.el7.centos                docker-ce-stable              30 M
Installing for dependencies:
 audit-libs-python                  x86_64             2.7.6-3.el7                            base                          73 k
 checkpolicy                        x86_64             2.5-4.el7                              base                         290 k
 container-selinux                  noarch             2:2.36-1.gitff95335.el7                extras                        31 k
 libcgroup                          x86_64             0.41-13.el7                            base                          65 k
 libsemanage-python                 x86_64             2.5-8.el7                              base                         104 k
 policycoreutils-python             x86_64             2.5-17.1.el7                           base                         446 k
 python-IPy                         noarch             0.75-6.el7                             base                          32 k
 setools-libs                       x86_64             3.3.8-1.1.el7                          base                         612 k

Transaction Summary
=================================================================================================================================

上記Installによって、Docker Groupが追加されている

[root@sugi-docker-registory ~]# cat /etc/group | grep docker
docker:x:993:

DockerがSystemdにServiceとして追加されている

[root@sugi-docker-registory ~]# systemctl status docker
● docker.service - Docker Application Container Engine
   Loaded: loaded (/usr/lib/systemd/system/docker.service; disabled; vendor preset: disabled)
   Active: inactive (dead)
     Docs: https://docs.docker.com

Dockerの起動 + 自動起動

systemctl start docker
systemctl enable docker

正常起動

dockerd と docker-containerd が起動されていることがわかります

[root@sugi-docker-registory ~]# systemctl status docker
● docker.service - Docker Application Container Engine
   Loaded: loaded (/usr/lib/systemd/system/docker.service; disabled; vendor preset: disabled)
   Active: active (running) since Sun 2018-02-18 15:28:27 JST; 7s ago
     Docs: https://docs.docker.com
 Main PID: 12097 (dockerd)
   Memory: 22.6M
   CGroup: /system.slice/docker.service
           ├─12097 /usr/bin/dockerd
           └─12102 docker-containerd --config /var/run/docker/containerd/containerd.toml

Feb 18 15:28:26 sugi-docker-registory.localdomain dockerd[12097]: time="2018-02-18T15:28:26+09:00" level=info msg=serving... address="/var/run/docker/containerd/docker-containerd.sock" module=...ainerd/grpc"
Feb 18 15:28:26 sugi-docker-registory.localdomain dockerd[12097]: time="2018-02-18T15:28:26+09:00" level=info msg="containerd successfully booted in 0.007210s" module=containerd
Feb 18 15:28:26 sugi-docker-registory.localdomain dockerd[12097]: time="2018-02-18T15:28:26.729217361+09:00" level=info msg="Graph migration to content-addressability took 0.00 seconds"
Feb 18 15:28:26 sugi-docker-registory.localdomain dockerd[12097]: time="2018-02-18T15:28:26.730328192+09:00" level=info msg="Loading containers: start."
Feb 18 15:28:27 sugi-docker-registory.localdomain dockerd[12097]: time="2018-02-18T15:28:27.014489988+09:00" level=info msg="Default bridge (docker0) is assigned with an IP address 172.17.0.0/... IP address"
Feb 18 15:28:27 sugi-docker-registory.localdomain dockerd[12097]: time="2018-02-18T15:28:27.098751802+09:00" level=info msg="Loading containers: done."
Feb 18 15:28:27 sugi-docker-registory.localdomain dockerd[12097]: time="2018-02-18T15:28:27.122713057+09:00" level=info msg="Docker daemon" commit=c97c6d6 graphdriver(s)=overlay2 version=17.12.0-ce
Feb 18 15:28:27 sugi-docker-registory.localdomain dockerd[12097]: time="2018-02-18T15:28:27.122888863+09:00" level=info msg="Daemon has completed initialization"
Feb 18 15:28:27 sugi-docker-registory.localdomain systemd[1]: Started Docker Application Container Engine.
Feb 18 15:28:27 sugi-docker-registory.localdomain dockerd[12097]: time="2018-02-18T15:28:27.145756482+09:00" level=info msg="API listen on /var/run/docker.sock"
Hint: Some lines were ellipsized, use -l to show in full.

現在は、何もコンテナが稼働していません

[root@sugi-docker-registory ~]# docker ps
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES

hello-worldイメージを実行して、正常にDockerが実行されたかを確認します

docker run hello-world

実行例

以下のように表示されれば、正常にInstall出来たことが確認できます。

下記実行後、自動的にコンテナは終了します。

[root@sugi-docker-registory ~]# docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
ca4f61b1923c: Pull complete
Digest: sha256:083de497cff944f969d8499ab94f07134c50bcf5e6b9559b27182d3fa80ce3f7
Status: Downloaded newer image for hello-world:latest

Hello from Docker!
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
 1. The Docker client contacted the Docker daemon.
 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
    (amd64)
 3. The Docker daemon created a new container from that image which runs the
    executable that produces the output you are currently reading.
 4. The Docker daemon streamed that output to the Docker client, which sent it
    to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
 $ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker ID:
 https://cloud.docker.com/

For more examples and ideas, visit:
 https://docs.docker.com/engine/userguide/

hello-worldイメージが自動的にダウンロードされています

[root@sugi-docker-registory ~]# docker image ls
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
hello-world         latest              f2a91732366c        2 months ago        1.85kB

Post-installation steps for Linux

Dockerがインストール出来た後、実行した方が良いConfigを実施していきます

Dockerをroot以外のユーザで実行する

Docker Daemon は、TCPポートの代わりに、Unix Domain Socketをバインドします。
Unix Domain Socket は、Defalutではrootユーザで実行されています。

memo netstatで、DockerのDefalutのUnix Domain Socket を確認

Docker文字列が含まれているもののみ抽出

[root@sugi-docker-registory ~]# netstat -al --protocol=unix
Active Internet connections (w/o servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State      
tcp        0      0 sugi-docker-registo:ssh 192.168.120.252:36080   ESTABLISHED
Active UNIX domain sockets (w/o servers)
Proto RefCnt Flags       Type       State         I-Node   Path
unix  2      [ ACC ]     STREAM     LISTENING     39986    /var/run/docker/metrics.sock
unix  2      [ ACC ]     STREAM     LISTENING     35130    /var/run/docker.sock
unix  2      [ ACC ]     STREAM     LISTENING     35146    /var/run/docker/containerd/docker-containerd-debug.sock
unix  2      [ ACC ]     STREAM     LISTENING     35148    /var/run/docker/containerd/docker-containerd.sock
unix  2      [ ACC ]     STREAM     LISTENING     40129    /run/docker/libnetwork/3726d3ce0f55fd85bda7654bdd8e9c22e6696c57fa5b90b21ec98a1c85f825a8.sock
unix  3      [ ]         STREAM     CONNECTED     35150    /var/run/docker/containerd/docker-containerd.sock
unix  3      [ ]         STREAM     CONNECTED     39992    /var/run/docker/containerd/docker-containerd.sock
unix  3      [ ]         STREAM     CONNECTED     35160    /var/run/docker/containerd/docker-containerd.sock

memo processがrootで実行されている

[root@sugi-docker-registory ~]# ps aux | grep docker
root     12097  0.1  0.9 468284 37828 ?        Ssl  15:28   0:02 /usr/bin/dockerd
root     12102  0.2  0.5 236444 22116 ?        Ssl  15:28   0:03 docker-containerd --config /var/run/docker/containerd/containerd.toml

Dockerを他のユーザで管理したい場合は、以下を実行します。

docker_user を作成します

useradd docker_user
echo 'Passw0rd!' | passwd --stdin docker_user
usermod -aG docker docker_user

docker_userにスイッチして、hello-worldを実行します。
正常に実行出来ればOKです

[root@sugi-docker-registory ~]# su - docker_user
Last login: Sun Feb 18 16:03:27 JST 2018 on pts/0
[docker_user@sugi-docker-registory ~]$
[docker_user@sugi-docker-registory ~]$ docker run hello-world

Hello from Docker!
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
 1. The Docker client contacted the Docker daemon.
 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
    (amd64)
 3. The Docker daemon created a new container from that image which runs the
    executable that produces the output you are currently reading.
 4. The Docker daemon streamed that output to the Docker client, which sent it
    to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
 $ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker ID:
 https://cloud.docker.com/

For more examples and ideas, visit:
 https://docs.docker.com/engine/userguide/

Storage Driverの選択

Dockerには、Storage Driverと呼ばれる、コンテナイメージの管理ドライバが存在します。
Volume Pluginと似た名前ですが、別物です。
以下URLにわかりやすく説明されています
https://knowledge.sakura.ad.jp/5021/

構築したDocker環境の情報を docker info コマンドで調べます。
Storage Driverは、Defaultで overlay2 が使用されています。
なお、Runtimesは、runCが実行されています。

[root@sugi-docker-registory ~]# docker info
Containers: 4
 Running: 0
 Paused: 0
 Stopped: 4
Images: 1
Server Version: 17.12.0-ce
Storage Driver: overlay2
 Backing Filesystem: xfs
 Supports d_type: true
 Native Overlay Diff: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
 Volume: local
 Network: bridge host macvlan null overlay
 Log: awslogs fluentd gcplogs gelf journald json-file logentries splunk syslog
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 89623f28b87a6004d4b785663257362d1658a729
runc version: b2567b37d7b75eb4cf325b77297b140ea686ce8f
init version: 949e6fa
Security Options:
 seccomp
  Profile: default
Kernel Version: 3.10.0-693.17.1.el7.x86_64
Operating System: CentOS Linux 7 (Core)
OSType: linux
Architecture: x86_64
CPUs: 2
Total Memory: 3.702GiB
Name: sugi-docker-registory.localdomain
ID: LQOF:D2EF:S7UT:4ZP5:YEUF:ARQ2:75RP:MMSS:I4BK:WIY7:3WB6:GJEO
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): false
Registry: https://index.docker.io/v1/
Labels:
Experimental: false
Insecure Registries:
 127.0.0.0/8
Live Restore Enabled: false

WARNING: bridge-nf-call-iptables is disabled
WARNING: bridge-nf-call-ip6tables is disabled

CentOSのCE版の推奨ストレージドライバは、devicemapperとvfsなので、devicemapperに変更します。
https://docs.docker.com/storage/storagedriver/select-storage-driver/#supported-storage-drivers-per-linux-distribution

なお、現時点でのlvmとdevice mapperのディレクトリを確認しておきます。
lvm

[root@sugi-docker-registory ~]# pvs
  PV         VG Fmt  Attr PSize    PFree
  /dev/sda2  cl lvm2 a--   <15.00g    0
  /dev/sda3  cl lvm2 a--  <184.00g    0
[root@sugi-docker-registory ~]#
[root@sugi-docker-registory ~]# lvs
  LV   VG Attr       LSize   Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  root cl -wi-ao---- 197.39g                                                    
  swap cl -wi-ao----   1.60g                                                    
[root@sugi-docker-registory ~]#
[root@sugi-docker-registory ~]# vgs
  VG #PV #LV #SN Attr   VSize   VFree
  cl   2   2   0 wz--n- 198.99g    0

device mapper

[root@sugi-docker-registory mapper]# ls -la
total 0
drwxr-xr-x  2 root root     100 Feb 18 14:29 .
drwxr-xr-x 19 root root    3180 Feb 18 14:29 ..
lrwxrwxrwx  1 root root       7 Feb 18 14:31 cl-root -> ../dm-0
lrwxrwxrwx  1 root root       7 Feb 18 14:29 cl-swap -> ../dm-1
crw-------  1 root root 10, 236 Feb 18 14:29 control

Storage Driverを変更すると、既に作成しているコンテナにはアクセスできなくなります。
docker save コマンドを使用して、 Docker Hub などのRepositoryに保存しておき、変更後に再度取得する必要があります。

devicemapperの設定には、テスト用の loop-lvm mode と 本番環境用の direct-lvm mode が存在します。
loop-lvmは、ファイルシステム上にLoopback Device を作成して稼働するため、パフォーマンスとリソース効率が悪いです。
本番環境では必ず direct-lvm mode を使用します。

direct-lvm mode で設定を進めます。

Docker を設定変更し、direct-lvm mode へ

direct-lvm mode へ変更するには、2種類の方法があります。
1個のdeviceしか使用できない自動設定と、複数のdeviceを使用できる、手動設定です。
構成を把握するために手動設定を進めていきます。

次の手順では、ストレージプールとして使用するために、Thin Pool の Logical Volume を LVM にて作成します。
今回は、direct-lvmとして、/dev/sdb のdeviceを使用します。

まず、Dockerを停止します

systemctl stop docker

pvcreate で Physical Volumeを作成します

pvcreate /dev/sdb

確認します

[root@sugi-docker-registory dev]# pvs
  PV         VG Fmt  Attr PSize    PFree  
  /dev/sda2  cl lvm2 a--   <15.00g      0
  /dev/sda3  cl lvm2 a--  <184.00g      0
  /dev/sdb      lvm2 ---   200.00g 200.00g

docker という名前で Volume Group を作成します

vgcreate docker /dev/sdb

確認します

[root@sugi-docker-registory dev]# vgs
  VG     #PV #LV #SN Attr   VSize    VFree   
  cl       2   2   0 wz--n-  198.99g       0
  docker   1   0   0 wz--n- <200.00g <200.00g

作成した Volume Group から 2個の Logical Volume を作成します

末尾の % の指定は Docker の推奨値です

lvcreate --wipesignatures y -n thinpool docker -l 95%VG
lvcreate --wipesignatures y -n thinpoolmeta docker -l 1%VG

確認します

[root@sugi-docker-registory dev]# lvs
  LV           VG     Attr       LSize    Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  root         cl     -wi-ao----  197.39g                                                    
  swap         cl     -wi-ao----    1.60g                                                    
  thinpool     docker -wi-a----- <190.00g                                                    
  thinpoolmeta docker -wi-a-----   <2.00g     

lvconvert コマンドで、Logical Volume を Thin に変換します

lvconvert --zero n -c 512K --thinpool docker/thinpool --poolmetadata docker/thinpoolmeta

実行例

[root@sugi-docker-registory dev]# lvconvert --zero n -c 512K --thinpool docker/thinpool --poolmetadata docker/thinpoolmeta
  Thin pool volume with chunk size 512.00 KiB can address at most 126.50 TiB of data.
  WARNING: Converting logical volume docker/thinpool and docker/thinpoolmeta to thin pool's data and metadata volumes with metadata wiping.
  THIS WILL DESTROY CONTENT OF LOGICAL VOLUME (filesystem etc.)
Do you really want to convert docker/thinpool and docker/thinpoolmeta? [y/n]: y
  Converted docker/thinpool_tdata to thin pool.

lvmのprofileを変更して、thin pool を自動拡張するようにします

thin_pool_autoextend_threshold は、自動拡張が発生した際に、X%までの使用量となるように指定します
thin_pool_autoextend_percent は、自動拡張が発生する残りの空き容量を指定します。

vi /etc/lvm/profile/docker-thinpool.profile
activation {
  thin_pool_autoextend_threshold=80
  thin_pool_autoextend_percent=20
}

profileを変更後、反映させます

lvchange --metadataprofile docker-thinpool docker/thinpool

実行例

[root@sugi-docker-registory dev]# lvchange --metadataprofile docker-thinpool docker/thinpool
  Logical volume docker/thinpool changed.

自動拡張のモニタリングを有効にします

lvs -o+seg_monitor

実行例

[root@sugi-docker-registory dev]# lvs -o+seg_monitor
  LV       VG     Attr       LSize    Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert Monitor  
  root     cl     -wi-ao----  197.39g                                                              
  root     cl     -wi-ao----  197.39g                                                              
  swap     cl     -wi-ao----    1.60g                                                              
  thinpool docker twi-a-t--- <190.00g             0.00   0.01                             monitored

過去に実行したDockerのファイルをoldへ移動します

mkdir /var/lib/docker.bk
mv /var/lib/docker/* /var/lib/docker.bk

/etc/docker/daemon.json を編集して、devicemapper を使用するようにします。
/etc/docker/daemon.json が空の場合は、以下のように設定してください

vim /etc/docker/daemon.json
{
    "storage-driver": "devicemapper",
    "storage-opts": [
      "dm.thinpooldev=/dev/mapper/docker-thinpool",
      "dm.use_deferred_removal=true",
      "dm.use_deferred_deletion=true"
    ]
}

docker を起動します

systemctl start docker

docker info を確認します

Storage Driverが devicemapper となっています。

[root@sugi-docker-registory docker]# docker info
Containers: 0
 Running: 0
 Paused: 0
 Stopped: 0
Images: 0
Server Version: 17.12.0-ce
Storage Driver: devicemapper
 Pool Name: docker-thinpool
 Pool Blocksize: 524.3kB
 Base Device Size: 10.74GB
 Backing Filesystem: xfs
 Udev Sync Supported: true
 Data Space Used: 20.45MB
 Data Space Total: 204GB
 Data Space Available: 204GB
 Metadata Space Used: 266.2kB
 Metadata Space Total: 2.143GB
 Metadata Space Available: 2.143GB
 Thin Pool Minimum Free Space: 20.4GB
 Deferred Removal Enabled: true
 Deferred Deletion Enabled: true
 Deferred Deleted Device Count: 0
 Library Version: 1.02.140-RHEL7 (2017-05-03)
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
 Volume: local
 Network: bridge host macvlan null overlay
 Log: awslogs fluentd gcplogs gelf journald json-file logentries splunk syslog
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 89623f28b87a6004d4b785663257362d1658a729
runc version: b2567b37d7b75eb4cf325b77297b140ea686ce8f
init version: 949e6fa
Security Options:
 seccomp
  Profile: default
Kernel Version: 3.10.0-693.17.1.el7.x86_64
Operating System: CentOS Linux 7 (Core)
OSType: linux
Architecture: x86_64
CPUs: 2
Total Memory: 3.702GiB
Name: sugi-docker-registory.localdomain
ID: LQOF:D2EF:S7UT:4ZP5:YEUF:ARQ2:75RP:MMSS:I4BK:WIY7:3WB6:GJEO
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): false
Registry: https://index.docker.io/v1/
Labels:
Experimental: false
Insecure Registries:
 127.0.0.0/8
Live Restore Enabled: false

WARNING: bridge-nf-call-iptables is disabled
WARNING: bridge-nf-call-ip6tables is disabled

oldへ移動したデータを全て削除します

rm -rf /var/lib/docker.bk

defaultのNW周りを確認

Docket NWを確認

[root@sugi-docker-registory ~]# docker network ls
NETWORK ID          NAME                DRIVER              SCOPE
3afcf241b318        bridge              bridge              local
329c0c8ffc50        host                host                local
f97b8d34a922        none                null                local

Linux Bridgeを確認する brctl コマンドを有効にするため、以下をinstallする

yum install bridge-utils

Default状態のLinuxBridgeを確認する

docker0という名前のBridgeが作成されている

[root@sugi-docker-registory ~]# brctl show
bridge name     bridge id               STP enabled     interfaces
docker0         8000.0242ac6ec522       no       

ipコマンドで確認

[root@sugi-docker-registory ~]# ip -d a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN qlen 1
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 promiscuity 0
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: ens192: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP qlen 1000
    link/ether 00:50:56:98:57:73 brd ff:ff:ff:ff:ff:ff promiscuity 0
    inet 192.168.120.210/24 brd 192.168.120.255 scope global ens192
       valid_lft forever preferred_lft forever
    inet6 fe80::98a0:413d:6b71:8fbd/64 scope link
       valid_lft forever preferred_lft forever
3: docker0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN
    link/ether 02:42:ac:6e:c5:22 brd ff:ff:ff:ff:ff:ff promiscuity 0
    bridge forward_delay 1500 hello_time 200 max_age 2000 ageing_time 30000 stp_state 0 priority 32768 vlan_filtering 0 vlan_protocol 802.1Q bridge_id 8000.2:42:ac:6e:c5:22 designated_root 8000.2:42:ac:6e:c5:22 root_port 0 root_path_cost 0 topology_change 0 topology_change_detected 0 hello_timer    0.00 tcn_timer    0.00 topology_change_timer    0.00 gc_timer    0.28 vlan_default_pvid 1 group_fwd_mask 0 group_address 01:80:c2:00:00:00 mcast_snooping 1 mcast_router 1 mcast_query_use_ifaddr 0 mcast_querier 0 mcast_hash_elasticity 4 mcast_hash_max 512 mcast_last_member_count 2 mcast_startup_query_count 2 mcast_last_member_interval 100 mcast_membership_interval 26000 mcast_querier_interval 25500 mcast_query_interval 12500 mcast_query_response_interval 1000 mcast_startup_query_interval 3125
    inet 172.17.0.1/16 brd 172.17.255.255 scope global docker0
       valid_lft forever preferred_lft forever
    inet6 fe80::42:acff:fe6e:c522/64 scope link
       valid_lft forever preferred_lft forever

iptablesでNAPTしているので、natテーブルを確認

[root@sugi-docker-registory ~]# iptables -L -t nat
Chain PREROUTING (policy ACCEPT)
target     prot opt source               destination         
DOCKER     all  --  anywhere             anywhere             ADDRTYPE match dst-type LOCAL

Chain INPUT (policy ACCEPT)
target     prot opt source               destination         

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination         
DOCKER     all  --  anywhere            !loopback/8           ADDRTYPE match dst-type LOCAL

Chain POSTROUTING (policy ACCEPT)
target     prot opt source               destination         
MASQUERADE  all  --  172.17.0.0/16        anywhere            

Chain DOCKER (2 references)
target     prot opt source               destination         
RETURN     all  --  anywhere             anywhere           

filterテーブルも確認

[root@sugi-docker-registory ~]# iptables -L -t filter
Chain INPUT (policy ACCEPT)
target     prot opt source               destination         

Chain FORWARD (policy DROP)
target     prot opt source               destination         
DOCKER-USER  all  --  anywhere             anywhere            
DOCKER-ISOLATION  all  --  anywhere             anywhere            
ACCEPT     all  --  anywhere             anywhere             ctstate RELATED,ESTABLISHED
DOCKER     all  --  anywhere             anywhere            
ACCEPT     all  --  anywhere             anywhere            
ACCEPT     all  --  anywhere             anywhere            

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination         

Chain DOCKER (1 references)
target     prot opt source               destination         

Chain DOCKER-ISOLATION (1 references)
target     prot opt source               destination         
RETURN     all  --  anywhere             anywhere            

Chain DOCKER-USER (1 references)
target     prot opt source               destination         
RETURN     all  --  anywhere             anywhere            

参考URL

Install
https://docs.docker.com/install/linux/docker-ce/centos/
https://docs.docker.com/install/linux/linux-postinstall/

Storage Driver
https://docs.docker.com/storage/storagedriver/select-storage-driver/#supported-storage-drivers-per-linux-distribution
https://docs.docker.com/storage/storagedriver/device-mapper-driver/

Unix Domain Socketのわかりやすい説明
https://qiita.com/kuni-nakaji/items/d11219e4ad7c74ece748

ボリュームプラグインとストレージドライバのわかりやすい説明
https://knowledge.sakura.ad.jp/5021/

8
18
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
8
18