LoginSignup
3
1

More than 1 year has passed since last update.

docker-ceをRHEL8へインストール

Posted at

docker-ceをインストールしたのでメモ

OSバージョン確認

# cat /etc/redhat-release
Red Hat Enterprise Linux release 8.3 (Ootpa)

リポジトリを追加

# dnf config-manager --add-repo=https://download.docker.com/linux/centos/docker-ce.repo
Updating Subscription Management repositories.
repo の追加: https://download.docker.com/linux/centos/docker-ce.repo

リポジトリの有効を確認

#  dnf repolist -v
ロードされたプラグイン: builddep, changelog, config-manager, copr, debug, debuginfo-install, download, generate_completion_cache, needs-restarting, playground, product-id, repoclosure, repodiff, repograph, repomanage, reposync, subscription-manager, uploadprofile
Updating Subscription Management repositories.
DNF version: 4.2.23
cachedir: /var/cache/dnf
Docker CE Stable - x86_64                                                                                                                                    9.1 kB/s |  14 kB     00:01
Repo-id            : docker-ce-stable
Repo-name          : Docker CE Stable - x86_64
Repo-revision      : 1622662057
Repo-updated       : 2021年06月03日 04時27分37秒
Repo-pkgs          : 38
Repo-available-pkgs: 38
Repo-size          : 937 M
Repo-baseurl       : https://download.docker.com/linux/centos/8.3/x86_64/stable
Repo-expire        : 172,800 秒 (最終: 2021年06月06日 18時05分46秒)
Repo-filename      : /etc/yum.repos.d/docker-ce.repo

Repo-id            : rhel-8-for-x86_64-appstream-rpms
Repo-name          : Red Hat Enterprise Linux 8 for x86_64 - AppStream (RPMs)
Repo-revision      : 1620325306
Repo-updated       : 2021年05月07日 03時21分46秒
Repo-pkgs          : 15,987
Repo-available-pkgs: 14,123
Repo-size          : 38 G
Repo-baseurl       : https://cdn.redhat.com/content/dist/rhel8/8.3/x86_64/appstream/os
Repo-expire        : 86,400 秒 (最終: 2021年06月06日 15時11分00秒)
Repo-filename      : /etc/yum.repos.d/redhat.repo

Repo-id            : rhel-8-for-x86_64-baseos-rpms
Repo-name          : Red Hat Enterprise Linux 8 for x86_64 - BaseOS (RPMs)
Repo-revision      : 1620884120
Repo-updated       : 2021年05月13日 14時35分17秒
Repo-pkgs          : 6,704
Repo-available-pkgs: 6,285
Repo-size          : 9.8 G
Repo-baseurl       : https://cdn.redhat.com/content/dist/rhel8/8.3/x86_64/baseos/os
Repo-expire        : 86,400 秒 (最終: 2021年06月06日 15時11分01秒)
Repo-filename      : /etc/yum.repos.d/redhat.repo
総パッケージ: 22,729

docker-ceのパッケージを確認

# dnf list docker-ce --showduplicates | sort -r
利用可能なパッケージ
メタデータの期限切れの最終確認: 0:03:35 時間前の 2021年06月06日 18時05分46秒 に実施しました。
docker-ce.x86_64                3:20.10.7-3.el8                 docker-ce-stable
docker-ce.x86_64                3:20.10.6-3.el8                 docker-ce-stable
docker-ce.x86_64                3:20.10.5-3.el8                 docker-ce-stable
docker-ce.x86_64                3:20.10.4-3.el8                 docker-ce-stable
docker-ce.x86_64                3:20.10.3-3.el8                 docker-ce-stable
docker-ce.x86_64                3:20.10.2-3.el8                 docker-ce-stable
docker-ce.x86_64                3:20.10.1-3.el8                 docker-ce-stable
docker-ce.x86_64                3:20.10.0-3.el8                 docker-ce-stable
docker-ce.x86_64                3:19.03.15-3.el8                docker-ce-stable
docker-ce.x86_64                3:19.03.14-3.el8                docker-ce-stable
docker-ce.x86_64                3:19.03.13-3.el8                docker-ce-stable
Updating Subscription Management repositories.

docker-ceをインストール

# dnf install docker-ce-3:20.10.7-3.el8
Updating Subscription Management repositories.
メタデータの期限切れの最終確認: 0:01:03 時間前の 2021年06月06日 18時11分12秒 に実施しました。
依存関係が解決しました。
=============================================================================================================================================================================================
 パッケージ                                  アーキテクチャー         バージョン                                                    リポジトリー                                       サイズ
=============================================================================================================================================================================================
インストール:
 docker-ce                                   x86_64                   3:20.10.7-3.el8                                               docker-ce-stable                                    27 M
依存関係のインストール:
 container-selinux                           noarch                   2:2.155.0-1.module+el8.3.1+9857+68fb1526                      rhel-8-for-x86_64-appstream-rpms                    51 k
 containerd.io                               x86_64                   1.4.6-3.1.el8                                                 docker-ce-stable                                    34 M
 docker-ce-cli                               x86_64                   1:20.10.7-3.el8                                               docker-ce-stable                                    33 M
 docker-ce-rootless-extras                   x86_64                   20.10.7-3.el8                                                 docker-ce-stable                                   9.2 M
 docker-scan-plugin                          x86_64                   0.8.0-3.el8                                                   docker-ce-stable                                   4.2 M
 fuse-overlayfs                              x86_64                   1.3.0-2.module+el8.3.1+9857+68fb1526                          rhel-8-for-x86_64-appstream-rpms                    72 k
 fuse3                                       x86_64                   3.2.1-12.el8                                                  rhel-8-for-x86_64-baseos-rpms                       50 k
 fuse3-libs                                  x86_64                   3.2.1-12.el8                                                  rhel-8-for-x86_64-baseos-rpms                       94 k
 libslirp                                    x86_64                   4.3.1-1.module+el8.3.1+9803+64eb0fd6                          rhel-8-for-x86_64-appstream-rpms                    69 k
 slirp4netns                                 x86_64                   1.1.8-1.module+el8.3.1+9857+68fb1526                          rhel-8-for-x86_64-appstream-rpms                    51 k
モジュールストリームの有効化中:
 container-tools                                                      rhel8

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

ダウンロードサイズの合計: 107 M
インストール済みのサイズ: 438 M
これでよろしいですか? [y/N]: y
パッケージのダウンロード:
(1/11): containerd.io-1.4.6-3.1.el8.x86_64.rpm                                                                                                               4.4 MB/s |  34 MB     00:07
(2/11): docker-ce-cli-20.10.7-3.el8.x86_64.rpm                                                                                                               4.0 MB/s |  33 MB     00:08
(3/11): docker-scan-plugin-0.8.0-3.el8.x86_64.rpm                                                                                                            2.4 MB/s | 4.2 MB     00:01
(4/11): docker-ce-rootless-extras-20.10.7-3.el8.x86_64.rpm                                                                                                   3.2 MB/s | 9.2 MB     00:02
(5/11): fuse-overlayfs-1.3.0-2.module+el8.3.1+9857+68fb1526.x86_64.rpm                                                                                       231 kB/s |  72 kB     00:00
(6/11): slirp4netns-1.1.8-1.module+el8.3.1+9857+68fb1526.x86_64.rpm                                                                                          267 kB/s |  51 kB     00:00
(7/11): container-selinux-2.155.0-1.module+el8.3.1+9857+68fb1526.noarch.rpm                                                                                  227 kB/s |  51 kB     00:00
(8/11): libslirp-4.3.1-1.module+el8.3.1+9803+64eb0fd6.x86_64.rpm                                                                                             378 kB/s |  69 kB     00:00
(9/11): fuse3-libs-3.2.1-12.el8.x86_64.rpm                                                                                                                   472 kB/s |  94 kB     00:00
(10/11): fuse3-3.2.1-12.el8.x86_64.rpm                                                                                                                       299 kB/s |  50 kB     00:00
(11/11): docker-ce-20.10.7-3.el8.x86_64.rpm                                                                                                                  1.8 MB/s |  27 MB     00:14
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
合計                                                                                                                                                         7.1 MB/s | 107 MB     00:14
警告: /var/cache/dnf/docker-ce-stable-97480ff917a24d63/packages/containerd.io-1.4.6-3.1.el8.x86_64.rpm: ヘッダー V4 RSA/SHA512 Signature、鍵 ID 621e9f35: NOKEY
Docker CE Stable - x86_64                                                                                                                                     29 kB/s | 1.6 kB     00:00
GPG 鍵 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
これでよろしいですか? [y/N]: y
鍵のインポートに成功しました
トランザクションの確認を実行中
トランザクションの確認に成功しました。
トランザクションのテストを実行中
トランザクションのテストに成功しました。
トランザクションを実行中
  準備             :                                                                                                                                                                     1/1
  インストール     : docker-scan-plugin-0.8.0-3.el8.x86_64                                                                                                                              1/11
  scriptletの実行中: docker-scan-plugin-0.8.0-3.el8.x86_64                                                                                                                              1/11
  インストール     : docker-ce-cli-1:20.10.7-3.el8.x86_64                                                                                                                               2/11
  scriptletの実行中: docker-ce-cli-1:20.10.7-3.el8.x86_64                                                                                                                               2/11
  scriptletの実行中: container-selinux-2:2.155.0-1.module+el8.3.1+9857+68fb1526.noarch                                                                                                  3/11
  インストール     : container-selinux-2:2.155.0-1.module+el8.3.1+9857+68fb1526.noarch                                                                                                  3/11
  scriptletの実行中: container-selinux-2:2.155.0-1.module+el8.3.1+9857+68fb1526.noarch                                                                                                  3/11
  インストール     : containerd.io-1.4.6-3.1.el8.x86_64                                                                                                                                 4/11
  scriptletの実行中: containerd.io-1.4.6-3.1.el8.x86_64                                                                                                                                 4/11
  インストール     : fuse3-3.2.1-12.el8.x86_64                                                                                                                                          5/11
  インストール     : fuse3-libs-3.2.1-12.el8.x86_64                                                                                                                                     6/11
  scriptletの実行中: fuse3-libs-3.2.1-12.el8.x86_64                                                                                                                                     6/11
  インストール     : fuse-overlayfs-1.3.0-2.module+el8.3.1+9857+68fb1526.x86_64                                                                                                         7/11
  scriptletの実行中: fuse-overlayfs-1.3.0-2.module+el8.3.1+9857+68fb1526.x86_64                                                                                                         7/11
  インストール     : libslirp-4.3.1-1.module+el8.3.1+9803+64eb0fd6.x86_64                                                                                                               8/11
  インストール     : slirp4netns-1.1.8-1.module+el8.3.1+9857+68fb1526.x86_64                                                                                                            9/11
  インストール     : docker-ce-rootless-extras-20.10.7-3.el8.x86_64                                                                                                                    10/11
  scriptletの実行中: docker-ce-rootless-extras-20.10.7-3.el8.x86_64                                                                                                                    10/11
  インストール     : docker-ce-3:20.10.7-3.el8.x86_64                                                                                                                                  11/11
  scriptletの実行中: docker-ce-3:20.10.7-3.el8.x86_64                                                                                                                                  11/11
  scriptletの実行中: container-selinux-2:2.155.0-1.module+el8.3.1+9857+68fb1526.noarch                                                                                                 11/11
  scriptletの実行中: docker-ce-3:20.10.7-3.el8.x86_64                                                                                                                                  11/11
  検証             : containerd.io-1.4.6-3.1.el8.x86_64                                                                                                                                 1/11
  検証             : docker-ce-3:20.10.7-3.el8.x86_64                                                                                                                                   2/11
  検証             : docker-ce-cli-1:20.10.7-3.el8.x86_64                                                                                                                               3/11
  検証             : docker-ce-rootless-extras-20.10.7-3.el8.x86_64                                                                                                                     4/11
  検証             : docker-scan-plugin-0.8.0-3.el8.x86_64                                                                                                                              5/11
  検証             : fuse-overlayfs-1.3.0-2.module+el8.3.1+9857+68fb1526.x86_64                                                                                                         6/11
  検証             : container-selinux-2:2.155.0-1.module+el8.3.1+9857+68fb1526.noarch                                                                                                  7/11
  検証             : slirp4netns-1.1.8-1.module+el8.3.1+9857+68fb1526.x86_64                                                                                                            8/11
  検証             : libslirp-4.3.1-1.module+el8.3.1+9803+64eb0fd6.x86_64                                                                                                               9/11
  検証             : fuse3-libs-3.2.1-12.el8.x86_64                                                                                                                                    10/11
  検証             : fuse3-3.2.1-12.el8.x86_64                                                                                                                                         11/11
Installed products updated.

インストール済み:
  container-selinux-2:2.155.0-1.module+el8.3.1+9857+68fb1526.noarch          containerd.io-1.4.6-3.1.el8.x86_64                               docker-ce-3:20.10.7-3.el8.x86_64
  docker-ce-cli-1:20.10.7-3.el8.x86_64                                       docker-ce-rootless-extras-20.10.7-3.el8.x86_64                   docker-scan-plugin-0.8.0-3.el8.x86_64
  fuse-overlayfs-1.3.0-2.module+el8.3.1+9857+68fb1526.x86_64                 fuse3-3.2.1-12.el8.x86_64                                        fuse3-libs-3.2.1-12.el8.x86_64
  libslirp-4.3.1-1.module+el8.3.1+9803+64eb0fd6.x86_64                       slirp4netns-1.1.8-1.module+el8.3.1+9857+68fb1526.x86_64

完了しました!

containerd.ioパッケージがインストールされていることを確認

# rpm -qa containerd.io*
containerd.io-1.4.6-3.1.el8.x86_64

firewallは無効であることを確認

# systemctl status firewalld.service
● firewalld.service - firewalld - dynamic firewall daemon
   Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled)
   Active: inactive (dead)
     Docs: man:firewalld(1)

Dockerデーモンを起動して有効にする

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

# systemctl status docker.service
● docker.service - Docker Application Container Engine
   Loaded: loaded (/usr/lib/systemd/system/docker.service; enabled; vendor preset: disabled)
   Active: active (running) since Sun 2021-06-06 18:25:54 JST; 1min 38s ago
     Docs: https://docs.docker.com
 Main PID: 6220 (dockerd)
    Tasks: 10
   Memory: 50.7M
   CGroup: /system.slice/docker.service
           mq6220 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock

dockerのバージョンを確認

# docker --version
Docker version 20.10.7, build f0df350

Dockerインストールのテスト

#  docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
b8dfde127a29: Pull complete
Digest: sha256:5122f6204b6a3596e048758cabba3c46b1c937a46b5be6225b835d091b90e46c
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://hub.docker.com/

For more examples and ideas, visit:
 https://docs.docker.com/get-started/

マシン上にダウンロードしたhello-worldイメージが一覧にあるかどうか確認

# docker images
REPOSITORY    TAG       IMAGE ID       CREATED        SIZE
hello-world   latest    d1165f221234   3 months ago   13.3kB

メッセージを表示して終了したhello-worldコンテナ(イメージから生成)が一覧にあるかを確認

# docker ps --all
CONTAINER ID   IMAGE         COMMAND    CREATED              STATUS                          PORTS     NAMES
2983356c7a93   hello-world   "/hello"   15 minutes ago       Exited (0) 7 minutes ago                  loving_curie

作成したコンテナを削除

# docker rm loving_curie
loving_curie

# docker images
REPOSITORY    TAG       IMAGE ID       CREATED        SIZE

以上ここまで

参考

・RHEL 8 / CentOS 8にDocker CEをインストールする方法
https://goto-linux.com/ja/2020/3/20/rhel-8-/-centos-8%E3%81%ABdocker-ce%E3%82%92%E3%82%A4%E3%83%B3%E3%82%B9%E3%83%88%E3%83%BC%E3%83%AB%E3%81%99%E3%82%8B%E6%96%B9%E6%B3%95/
・Docker-docs-ja
http://docs.docker.jp/get-started/index.html

3
1
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
3
1