0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

[自分用メモ]Dockerのインストール

Last updated at Posted at 2025-02-09

CentOSのリポジトリを変更

  1. rootユーザに移行する

  2. yumのリポジトリファイルを開く

    sudo vim /etc/yum.repos.d/CentOS-Base.repo
    
  3. baseurlを設定

    [base]、[updates]、[extras]のmirrorlistをコメントアウトして、baseurlを以下のように設定する

    baseurl=http://vault.centos.org/7.9.2009/os/$basearch/
    

    設定ファイルの内容サンプルは以下

    CentOS-Base.repo
    [base]
    name=CentOS-$releasever - Base
    #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os
    baseurl=http://vault.centos.org/7.9.2009/os/$basearch/
    enabled=1
    gpgcheck=1
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
    
    [updates]
    name=CentOS-$releasever - Updates
    #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates
    baseurl=http://vault.centos.org/7.9.2009/updates/$basearch/
    enabled=1
    gpgcheck=1
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
    
    [extras]
    name=CentOS-$releasever - Extras
    #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras
    baseurl=http://vault.centos.org/7.9.2009/extras/$basearch/
    enabled=1
    gpgcheck=1
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
    
  4. リポジトリのキャッシュをクリアする

    sudo yum clean all
    
  5. updateコマンドを実行する

    sudo yum update
    

Dockerのインストール

  1. (過去にDocekerをインストールしている場合のみ)古いバージョンのDockerをアンインストール

    sudo yum remove docker \ docker-client \ docker-common \ docker-engine
    
    
  2. 必要なパッケージをインストール

    sudo yum install yum-utils
    
  3. Dockerのリポジトリを追加

    sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
    
  4. Dockerをインストール

    sudo yum install docker-ce
    
    1. エラー対処

      以下のエラーが発生する可能性がある。これはDockerリポジトリからDocker CEの依存パッケージ(container-selinuxslirp4netnsfuse-overlayfs) が見つからないために発生する

      エラー: パッケージ: containerd.io-1.6.33-3.1.el7.x86_64 (download.docker.com_linux_centos_7_x86_64_stable_)
                   要求: container-selinux >= 2:2.74
      エラー: パッケージ: docker-ce-rootless-extras-26.1.4-1.el7.x86_64 (download.docker.com_linux_centos_7_x86_64_stable_)
                   要求: slirp4netns >= 0.4
      エラー: パッケージ: docker-ce-rootless-extras-26.1.4-1.el7.x86_64 (download.docker.com_linux_centos_7_x86_64_stable_)
                   要求: fuse-overlayfs >= 0.7
      エラー: パッケージ: 3:docker-ce-26.1.4-1.el7.x86_64 (download.docker.com_linux_centos_7_x86_64_stable_)
                   要求: container-selinux >= 2:2.74
       問題を回避するために --skip-broken を用いることができます。
       これらを試行できます: rpm -Va --nofiles --nodigest
      
    2. (メモ)パッケージのインストール方法

      1. container-selinux

        Extraリポジトリ、EPLEリポジトリには存在しない(yum serachで取得できない)
        このため、MIRACLE LINUXのサイトからRPMファイルをインストールする

        https://tsn.miraclelinux.com/system/files/AXS7/x86_64/UPDATE/RPMS/container-selinux-2.119.2-1.911c772.el7.noarch.rpm
        コマンドは以下

        sudo yum install https://tsn.miraclelinux.com/system/files/AXS7/x86_64/UPDATE/RPMS/container-selinux-2.119.2-1.911c772.el7.noarch.rpm
        
      2. fuse-overlayfs

        Extraリポジトリ、EPLEリポジトリには存在しない(yum serachで取得できない)
        このため、MIRACLE LINUXのサイトからRPMファイルをインストールする

        https://tsn.miraclelinux.com/system/files/AXS7/x86_64/UPDATE/RPMS/fuse-overlayfs-0.7.2-6.el7.x86_64.rpm

        コマンドは以下

        sudo yum install https://tsn.miraclelinux.com/system/files/AXS7/x86_64/UPDATE/RPMS/fuse-overlayfs-0.7.2-6.el7.x86_64.rpm
        
      3. slirp4netns

        Extraリポジトリ、EPLEリポジトリには存在しない(yum serachで取得できない)
        このため、MIRACLE LINUXのサイトからRPMファイルをインストールする

        https://tsn.miraclelinux.com/system/files/AXS7/x86_64/UPDATE/RPMS/slirp4netns-0.4.3-4.el7.x86_64.rpm

        コマンドは以下

        sudo yum install https://tsn.miraclelinux.com/system/files/AXS7/x86_64/UPDATE/RPMS/slirp4netns-0.4.3-4.el7.x86_64.rpm
        
    3. 再度、Dockerをインストール

      sudo yum install docker-ce
      
  5. Dockerサービスを起動

    sudo systemctl start docker
    
  6. (必要に応じて)Dockerサービスを自動起動するように設定

    sudo systemctl enable docker
    
  7. Dockerを起動

    sudo systemctl start docker
    
  8. Dockerが起動してるか確認

    sudo systemctl status docker
    
  9. 【補足】Dockerコマンドを実行する際にsudoが必要なくなるように、ユーザーをdockerグループに追加

    sudo usermod -aG docker vboxuser newgrp docker
    
0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?