h9803660ブログ

ネットワーク関連の技術検証のメモ、ネットワーク製品動向、投資のこと等を気が向いた時に書くかもしれません。

CentOS8にDocker/Docker Composeをインストール

自分向けのDocker/DockerComposeインストールメモ(CentOS8利用)

Docker

1.リポジトリの確認

dnf repolist
repo id                            repo name
AppStream                          CentOS-8 - AppStream
BaseOS                             CentOS-8 - Base
extras                             CentOS-8 - Extras

2.リポジトリの追加及び追加されたことの確認

dnf config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
Adding repo from: https://download.docker.com/linux/centos/docker-ce.repo

 dnf repolist
repo id                             repo name
AppStream                           CentOS-8 - AppStream
BaseOS                              CentOS-8 - Base
docker-ce-stable                    Docker CE Stable - x86_64
extras                              CentOS-8 - Extras

3.インストール

dnf -y install --nobest docker-ce docker-ce-cli
Docker CE Stable - x86_64                        17 kB/s | 3.8 kB     00:00
Dependencies resolved.
================================================================================
 Package                      Arch   Version             Repository        Size
================================================================================
Installing:
 docker-ce                    x86_64 3:19.03.13-3.el8    docker-ce-stable  24 M
 docker-ce-cli                x86_64 1:19.03.13-3.el8    docker-ce-stable  38 M
Installing dependencies:
 checkpolicy                  x86_64 2.9-1.el8           BaseOS           348 k
 container-selinux            noarch 2:2.124.0-1.module_el8.2.0+305+5e198a41
                                                         AppStream         47 k
 containerd.io                x86_64 1.3.7-3.1.el8       docker-ce-stable  29 M
 libcgroup                    x86_64 0.41-19.el8         BaseOS            70 k
 policycoreutils-python-utils noarch 2.9-9.el8           BaseOS           251 k
 python3-audit                x86_64 3.0-0.17.20191104git1c2f876.el8
                                                         BaseOS            86 k
 python3-libsemanage          x86_64 2.9-2.el8           BaseOS           127 k
 python3-policycoreutils      noarch 2.9-9.el8           BaseOS           2.2 M
 python3-setools              x86_64 4.2.2-2.el8         BaseOS           601 k
Enabling module streams:
 container-tools                     rhel8

Transaction Summary
================================================================================
Install  11 Packages

Total download size: 95 M
Installed size: 395 M
Downloading Packages:
(1/11): libcgroup-0.41-19.el8.x86_64.rpm        2.2 kB/s |  70 kB     00:31
(2/11): container-selinux-2.124.0-1.module_el8. 1.0 kB/s |  47 kB     00:48
[MIRROR] python3-audit-3.0-0.17.20191104git1c2f876.el8.x86_64.rpm: Curl error (28): Timeout was reached for http://mirror.centos.org/centos/8/BaseOS/x86_64/os/Packages/python3-audit-3.0-0.17.20191104git1c2f876.el8.x86_64.rpm [Operation too slow. Less than 1000 bytes/sec transferred the last 30 seconds]
(3/11): containerd.io-1.3.7-3.1.el8.x86_64.rpm  6.0 MB/s |  29 MB     00:04
(4/11): docker-ce-19.03.13-3.el8.x86_64.rpm     7.5 MB/s |  24 MB     00:03
[MIRROR] checkpolicy-2.9-1.el8.x86_64.rpm: Curl error (28): Timeout was reached for http://mirror.centos.org/centos/8/BaseOS/x86_64/os/Packages/checkpolicy-2.9-1.el8.x86_64.rpm [Operation too slow. Less than 1000 bytes/sec transferred the last 30 seconds]
(5/11): docker-ce-cli-19.03.13-3.el8.x86_64.rpm 7.0 MB/s |  38 MB     00:05
(6/11): policycoreutils-python-utils-2.9-9.el8. 1.7 kB/s | 251 kB     02:31
(7/11): checkpolicy-2.9-1.el8.x86_64.rpm        1.9 kB/s | 348 kB     03:03
(8/11): python3-audit-3.0-0.17.20191104git1c2f8 649  B/s |  86 kB     02:15
(9/11): python3-libsemanage-2.9-2.el8.x86_64.rp 812 kB/s | 127 kB     00:00
(10/11): python3-policycoreutils-2.9-9.el8.noar 3.6 MB/s | 2.2 MB     00:00
(11/11): python3-setools-4.2.2-2.el8.x86_64.rpm 1.2 MB/s | 601 kB     00:00
--------------------------------------------------------------------------------
Total                                           523 kB/s |  95 MB     03:06
warning: /var/cache/dnf/docker-ce-stable-fa9dc42ab4cec2f4/packages/containerd.io-1.3.7-3.1.el8.x86_64.rpm: Header V4 RSA/SHA512 Signature, key ID 621e9f35: NOKEY
Docker CE Stable - x86_64                        25 kB/s | 1.6 kB     00:00
Importing GPG key 0x621E9F35:
 Userid     : "Docker Release (CE rpm) <docker@docker.com>"
 Fingerprint: 060A 61C5 1B55 8A7F 742B 77AA C52F EB6B 621E 9F35
 From       : https://download.docker.com/linux/centos/gpg
Key imported successfully
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                        1/1
  Installing       : docker-ce-cli-1:19.03.13-3.el8.x86_64                 1/11
  Running scriptlet: docker-ce-cli-1:19.03.13-3.el8.x86_64                 1/11
  Installing       : python3-setools-4.2.2-2.el8.x86_64                    2/11
  Installing       : python3-libsemanage-2.9-2.el8.x86_64                  3/11
  Installing       : python3-audit-3.0-0.17.20191104git1c2f876.el8.x86_    4/11
  Running scriptlet: libcgroup-0.41-19.el8.x86_64                          5/11
  Installing       : libcgroup-0.41-19.el8.x86_64                          5/11
  Running scriptlet: libcgroup-0.41-19.el8.x86_64                          5/11
  Installing       : checkpolicy-2.9-1.el8.x86_64                          6/11
  Installing       : python3-policycoreutils-2.9-9.el8.noarch              7/11
  Installing       : policycoreutils-python-utils-2.9-9.el8.noarch         8/11
  Running scriptlet: container-selinux-2:2.124.0-1.module_el8.2.0+305+5    9/11
  Installing       : container-selinux-2:2.124.0-1.module_el8.2.0+305+5    9/11
  Running scriptlet: container-selinux-2:2.124.0-1.module_el8.2.0+305+5    9/11
  Installing       : containerd.io-1.3.7-3.1.el8.x86_64                   10/11
  Running scriptlet: containerd.io-1.3.7-3.1.el8.x86_64                   10/11
  Installing       : docker-ce-3:19.03.13-3.el8.x86_64                    11/11
  Running scriptlet: docker-ce-3:19.03.13-3.el8.x86_64                    11/11
  Running scriptlet: container-selinux-2:2.124.0-1.module_el8.2.0+305+5   11/11
  Running scriptlet: docker-ce-3:19.03.13-3.el8.x86_64                    11/11
  Verifying        : container-selinux-2:2.124.0-1.module_el8.2.0+305+5    1/11
  Verifying        : checkpolicy-2.9-1.el8.x86_64                          2/11
  Verifying        : libcgroup-0.41-19.el8.x86_64                          3/11
  Verifying        : policycoreutils-python-utils-2.9-9.el8.noarch         4/11
  Verifying        : python3-audit-3.0-0.17.20191104git1c2f876.el8.x86_    5/11
  Verifying        : python3-libsemanage-2.9-2.el8.x86_64                  6/11
  Verifying        : python3-policycoreutils-2.9-9.el8.noarch              7/11
  Verifying        : python3-setools-4.2.2-2.el8.x86_64                    8/11
  Verifying        : containerd.io-1.3.7-3.1.el8.x86_64                    9/11
  Verifying        : docker-ce-3:19.03.13-3.el8.x86_64                    10/11
  Verifying        : docker-ce-cli-1:19.03.13-3.el8.x86_64                11/11

Installed:
  checkpolicy-2.9-1.el8.x86_64
  container-selinux-2:2.124.0-1.module_el8.2.0+305+5e198a41.noarch
  containerd.io-1.3.7-3.1.el8.x86_64
  docker-ce-3:19.03.13-3.el8.x86_64
  docker-ce-cli-1:19.03.13-3.el8.x86_64
  libcgroup-0.41-19.el8.x86_64
  policycoreutils-python-utils-2.9-9.el8.noarch
  python3-audit-3.0-0.17.20191104git1c2f876.el8.x86_64
  python3-libsemanage-2.9-2.el8.x86_64
  python3-policycoreutils-2.9-9.el8.noarch
  python3-setools-4.2.2-2.el8.x86_64

Complete!

4.Dockerの起動と自動起動設定

systemctl start docker
systemctl enable docker
Created symlink /etc/systemd/system/multi-user.target.wants/docker.service → /usr/lib/systemd/system/docker.service.

5.確認

docker --version
Docker version 19.03.13, build 4484c46d9d

Docker Compose

githubの最新のリリース版を見つけて手順に沿ってインストール(2020/11/22時点では1.27.4だった)

matsuand.github.io

curl -L "https://github.com/docker/compose/releases/download/1.27.4/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   651  100   651    0     0   1503      0 --:--:-- --:--:-- --:--:--  1506
100 11.6M  100 11.6M    0     0   778k      0  0:00:15  0:00:15 --:--:--  939k

パーミッション変更

chmod +x /usr/local/bin/docker-compose

バージョン確認

docker-compose --version
docker-compose version 1.27.4, build 40524192