CentOS7.9に最新版のdockerとdocker-composeをインストールする

環境
# cat /etc/redhat-release
CentOS Linux release 7.9.2009 (Core)

操作方法
1.システムアップデートを行います

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
# sudo yum update
# sudo yum upgrade
# sudo yum update # sudo yum upgrade
# sudo yum update
# sudo yum upgrade

2.関連パッケージをインストールします

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
# sudo yum install -y yum-utils device-mapper-persistent-data lvm2
# sudo yum install -y yum-utils device-mapper-persistent-data lvm2
# sudo yum install -y yum-utils device-mapper-persistent-data lvm2

リポジトリを追加します

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
# sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
読み込んだプラグイン:fastestmirror, langpacks
adding repo from: https://download.docker.com/linux/centos/docker-ce.repo
grabbing file https://download.docker.com/linux/centos/docker-ce.repo to /etc/yum.repos.d/docker-ce.repo
repo saved to /etc/yum.repos.d/docker-ce.repo
# sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo 読み込んだプラグイン:fastestmirror, langpacks adding repo from: https://download.docker.com/linux/centos/docker-ce.repo grabbing file https://download.docker.com/linux/centos/docker-ce.repo to /etc/yum.repos.d/docker-ce.repo repo saved to /etc/yum.repos.d/docker-ce.repo
# sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
読み込んだプラグイン:fastestmirror, langpacks
adding repo from: https://download.docker.com/linux/centos/docker-ce.repo
grabbing file https://download.docker.com/linux/centos/docker-ce.repo to /etc/yum.repos.d/docker-ce.repo
repo saved to /etc/yum.repos.d/docker-ce.repo

3.dockerのCEをインストールします

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
# sudo yum install -y docker-ce docker-ce-cli containerd.io
# sudo yum install -y docker-ce docker-ce-cli containerd.io
# sudo yum install -y docker-ce docker-ce-cli containerd.io

4.dockerを起動します
自動起動の設定

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
# sudo systemctl enable --now docker
# sudo systemctl enable --now docker
# sudo systemctl enable --now docker

バージョンを確認します

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
# docker --version
Docker version 20.10.13, build a224086
# docker --version Docker version 20.10.13, build a224086
# docker --version
Docker version 20.10.13, build a224086

5.docker-composeをインストールします
下記サイトで最新版をダウンロードします
https://github.com/docker/compose/releases
docker-compose2.3.3をダウンロードします

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
# curl -L https://github.com/docker/compose/releases/download/v2.3.3/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose
# curl -L https://github.com/docker/compose/releases/download/v2.3.3/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose
# curl -L https://github.com/docker/compose/releases/download/v2.3.3/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose

実行権限を付与します

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
# sudo chmod +x /usr/local/bin/docker-compose
# sudo chmod +x /usr/local/bin/docker-compose
# sudo chmod +x /usr/local/bin/docker-compose

docker-composeバージョンを確認します

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
# docker-compose version
Docker Compose version v2.3.3
# docker-compose version Docker Compose version v2.3.3
# docker-compose version
Docker Compose version v2.3.3

 

CentOS 7

Posted by arkgame