・Oracle Linux8にDockeをインストールしてコンテナ仮想環境を構築したい。
・具体的な手順を教えてほしい。
こういった疑問に答えます。
本記事の内容
- Oracle Linux8にDocker CEをインストールしてコンテナ仮想環境を構築する手順
この記事を書いている私は、某SIerに勤務しながら、
WEB系エンジニア・インフラエンジニアに憧れて、プログラミングおよびインフラ技術の勉強をしています。
こういった私が、解説していきます。
私が実機で試したコマンドや画像を載せて書いています。
記事の信頼性担保に繋がると思います。
- 本記事の内容
- Oracle Linux8にDocker CEをインストールしてコンテナ仮想環境を構築する手順
- 前提条件
- 手順①:古いバージョンをアンインストール
- 手順②:Dockerリポジトリをセットアップ
- 手順③:Docker Engineをインストール
- 手順④:dockerdの起動および自動起動の設定
- 手順⑤:Dockerの動作確認
- コンテナ作成実行の簡易テスト
- Dockerの基本コマンドを一通り使ってみる
- さらにDockerについて勉強したい方におすすめの書籍
- インフラエンジニアの勉強ができるオンライン学習サイト
Oracle Linux8にDocker CEをインストールしてコンテナ仮想環境を構築する手順
Dockerの無償版「Community Edition (CE)」は、CentOS7とCentOS8に対応しているようですが、今回は、Oracle Linux8にインストールしてみます。
Install Docker Engine on CentOS
下記ページに、CentOSへのDockerインストール手順が書かれているので、
基本はこれに沿って進めていきます。
OS requirements
To install Docker Engine, you need a maintained version of CentOS 7 or 8. Archived versions aren’t supported or tested.The
centos-extras
repository must be enabled. This repository is enabled by default, but if you have disabled it, you need to re-enable it.The
overlay2
storage driver is recommended.OSの要件
Docker Engineをインストールするには、CentOS 7または8の保守バージョンが必要です。アーカイブバージョンはサポートまたはテストされていません。
centos-extras
リポジトリを有効にする必要があります。このリポジトリはデフォルトで有効になっていますが、無効にしている場合は、再度有効にする必要があります 。
overlay2
ストレージドライバが推奨されます。
Install Docker Engine on CentOS https://docs.docker.com/engine/install/centos/
前提条件
今回の環境は、以下の手順で構築したOracle Linux8サーバーを使います。
手順①:古いバージョンをアンインストール
ドッカーの古いバージョンdocker
かdocker-engine
がインストールされている場合は、
関連する依存関係とともにアンインストールします。
dnf remove docker
dnf remove docker-client
dnf remove docker-client-lates
dnf remove docker-common
dnf remove docker-latest
dnf remove docker-latest-logrotate
dnf remove docker-loglotate
dnf remove docker-engine
[root@SV-TITAN ~]# dnf remove docker-client 一致した引数がありません: docker-client 削除対象のパッケージはありません。 依存関係が解決しました。 行うべきことはありません。 完了しました!
[root@SV-TITAN ~]# dnf remove docker-client-lates 一致した引数がありません: docker-client-lates 削除対象のパッケージはありません。 依存関係が解決しました。 行うべきことはありません。 完了しました!
[root@SV-TITAN ~]# dnf remove docker-common 一致した引数がありません: docker-common 削除対象のパッケージはありません。 依存関係が解決しました。 行うべきことはありません。 完了しました!
[root@SV-TITAN ~]# dnf remove docker-latest 一致した引数がありません: docker-latest 削除対象のパッケージはありません。 依存関係が解決しました。 行うべきことはありません。 完了しました!
[root@SV-TITAN ~]# dnf remove docker-latest-logrotate 一致した引数がありません: docker-latest-logrotate 削除対象のパッケージはありません。 依存関係が解決しました。 行うべきことはありません。 完了しました!
[root@SV-TITAN ~]# dnf remove docker-loglotate 一致した引数がありません: docker-loglotate 削除対象のパッケージはありません。 依存関係が解決しました。 行うべきことはありません。 完了しました!
[root@SV-TITAN ~]# dnf remove docker-engine 一致した引数がありません: docker-engine 削除対象のパッケージはありません。 依存関係が解決しました。 行うべきことはありません。 完了しました!
手順②:Dockerリポジトリをセットアップ
現在のリポジトリの確認
dnf repolist
[root@SV-TITAN ~]# dnf repolist repo id repo の名前 ol8_UEKR6 Latest Unbreakable Enterprise Kernel Release 6 for Oracle Linux 8 (x86_64) ol8_appstream Oracle Linux 8 Application Stream (x86_64) ol8_baseos_latest Oracle Linux 8 BaseOS Latest (x86_64)
Dockerリポジトリの追加
dnf config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
[root@SV-TITAN ~]# dnf config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo repo の追加: https://download.docker.com/linux/centos/docker-ce.repo
追加後のリポジトリの確認
dnf repolist
[root@SV-TITAN ~]# dnf repolist repo id repo の名前 docker-ce-stable Docker CE Stable - x86_64 ol8_UEKR6 Latest Unbreakable Enterprise Kernel Release 6 for Oracle Linux 8 (x86_64) ol8_appstream Oracle Linux 8 Application Stream (x86_64) ol8_baseos_latest Oracle Linux 8 BaseOS Latest (x86_64)
Docker CE Stable
が有効になりました。
手順③:Docker Engineをインストール
docker-ce関連のパッケージの詳細を確認
dnf info docker-ce docker-ce-cli containerd.io
[root@SV-TITAN ~]# dnf info docker-ce docker-ce-cli containerd.io Docker CE Stable - x86_64 47 kB/s | 7.8 kB 00:00 利用可能なパッケージ 名前 : containerd.io バージョン : 1.4.3 リリース : 3.1.el8 Arch : x86_64 サイズ : 33 M ソース : containerd.io-1.4.3-3.1.el8.src.rpm リポジトリー : docker-ce-stable 概要 : An industry-standard container runtime URL : https://containerd.io ライセンス : ASL 2.0 説明 : containerd is an industry-standard container runtime with an emphasis on : simplicity, robustness and portability. It is available as a daemon for Linux : and Windows, which can manage the complete container lifecycle of its host : system: image transfer and storage, container execution and supervision, : low-level storage and network attachments, etc. 名前 : docker-ce エポック : 3 バージョン : 20.10.2 リリース : 3.el8 Arch : x86_64 サイズ : 27 M ソース : docker-ce-20.10.2-3.el8.src.rpm リポジトリー : docker-ce-stable 概要 : The open-source application container engine URL : https://www.docker.com ライセンス : ASL 2.0 説明 : Docker is a product for you to build, ship and run any application as a : lightweight container. : Docker containers are both hardware-agnostic and platform-agnostic. This means : they can run anywhere, from your laptop to the largest cloud compute instance and : everything in between - and they don't require you to use a particular : language, framework or packaging system. That makes them great building blocks : for deploying and scaling web apps, databases, and backend services without : depending on a particular stack or provider. 名前 : docker-ce-cli エポック : 1 バージョン : 20.10.2 リリース : 3.el8 Arch : x86_64 サイズ : 33 M ソース : docker-ce-cli-20.10.2-3.el8.src.rpm リポジトリー : docker-ce-stable 概要 : The open-source application container engine URL : https://www.docker.com ライセンス : ASL 2.0 説明 : Docker is is a product for you to build, ship and run any application as a : lightweight container. : Docker containers are both hardware-agnostic and platform-agnostic. This means : they can run anywhere, from your laptop to the largest cloud compute instance and : everything in between - and they don't require you to use a particular : language, framework or packaging system. That makes them great building blocks : for deploying and scaling web apps, databases, and backend services without : depending on a particular stack or provider.
docker-ceパッケージのインストール (podmanとbuildahの競合でエラー)
dnf install docker-ce docker-ce-cli containerd.io
[root@SV-TITAN ~]# dnf install docker-ce docker-ce-cli containerd.io メタデータの期限切れの最終確認: 0:01:22 時間前の 2021年01月11日 11時19分31秒 に実施しました。 エラー: 問題 1: problem with installed package podman-2.0.5-5.0.1.module+el8.3.0+7866+f387f528.x86_64 - package podman-2.0.5-5.0.1.module+el8.3.0+7866+f387f528.x86_64 requires runc >= 1.0.0-57, but none of the providers can be installed - package podman-1.0.0-2.0.1.git921f98f.module+el8+5201+6423ecab.x86_64 requires runc, but none of the providers can be installed - package podman-1.0.0-2.0.1.git921f98f.module+el8.0.0+5215+77f672ad.x86_64 requires runc, but none of the providers can be installed - package podman-1.0.3-1.0.1.git9d78c0c.module+el8.0.0.z+5239+bd2c200f.x86_64 requires runc, but none of the providers can be installed - package podman-1.0.5-1.gitf604175.0.1.module+el8.0.0+5336+de35ffea.x86_64 requires runc, but none of the providers can be installed - package podman-1.4.2-5.0.2.module+el8.1.0+5440+994fc847.x86_64 requires runc, but none of the providers can be installed - package podman-1.4.2-6.0.1.module+el8.1.0+5460+5d763c32.x86_64 requires runc, but none of the providers can be installed - package podman-1.6.4-10.0.1.module+el8.2.0+5584+b2b2d3fb.x86_64 requires runc >= 1.0.0-57, but none of the providers can be installed - package podman-1.6.4-11.0.1.module+el8.2.0+7615+180dc822.x86_64 requires runc >= 1.0.0-57, but none of the providers can be installed - package podman-1.6.4-11.0.2.module+el8.2.0+7622+50d25570.x86_64 requires runc >= 1.0.0-57, but none of the providers can be installed - package podman-1.6.4-12.0.2.module+el8.2.0+7629+69f5cbc6.x86_64 requires runc >= 1.0.0-57, but none of the providers can be installed - package podman-1.6.4-2.0.1.module+el8.1.1+5502+fbec5cc6.x86_64 requires runc >= 1.0.0-57, but none of the providers can be installed - package podman-1.6.4-4.0.1.module+el8.1.1+5573+1c3f6079.x86_64 requires runc >= 1.0.0-57, but none of the providers can be installed - package podman-1.9.3-2.0.1.module+el8.2.1+7658+86e51d52.x86_64 requires runc >= 1.0.0-57, but none of the providers can be installed - package containerd.io-1.4.3-3.1.el8.x86_64 conflicts with runc provided by runc-1.0.0-68.rc92.module+el8.3.0+7866+f387f528.x86_64 - package containerd.io-1.4.3-3.1.el8.x86_64 obsoletes runc provided by runc-1.0.0-68.rc92.module+el8.3.0+7866+f387f528.x86_64 - package containerd.io-1.4.3-3.1.el8.x86_64 conflicts with runc provided by runc-1.0.0-54.rc5.dev.git2abd837.module+el8+5201+6423ecab.x86_64 - package containerd.io-1.4.3-3.1.el8.x86_64 obsoletes runc provided by runc-1.0.0-54.rc5.dev.git2abd837.module+el8+5201+6423ecab.x86_64 - package containerd.io-1.4.3-3.1.el8.x86_64 conflicts with runc provided by runc-1.0.0-55.rc5.dev.git2abd837.module+el8.0.0+5215+77f672ad.x86_64 - package containerd.io-1.4.3-3.1.el8.x86_64 obsoletes runc provided by runc-1.0.0-55.rc5.dev.git2abd837.module+el8.0.0+5215+77f672ad.x86_64 - package containerd.io-1.4.3-3.1.el8.x86_64 conflicts with runc provided by runc-1.0.0-55.rc5.dev.git2abd837.module+el8.0.0.z+5239+bd2c200f.x86_64 - package containerd.io-1.4.3-3.1.el8.x86_64 obsoletes runc provided by runc-1.0.0-55.rc5.dev.git2abd837.module+el8.0.0.z+5239+bd2c200f.x86_64 - package containerd.io-1.4.3-3.1.el8.x86_64 conflicts with runc provided by runc-1.0.0-56.rc8.dev.git425e105.module+el8.0.0+5336+de35ffea.x86_64 - package containerd.io-1.4.3-3.1.el8.x86_64 obsoletes runc provided by runc-1.0.0-56.rc8.dev.git425e105.module+el8.0.0+5336+de35ffea.x86_64 - package containerd.io-1.4.3-3.1.el8.x86_64 conflicts with runc provided by runc-1.0.0-60.rc8.module+el8.1.0+5440+994fc847.x86_64 - package containerd.io-1.4.3-3.1.el8.x86_64 obsoletes runc provided by runc-1.0.0-60.rc8.module+el8.1.0+5440+994fc847.x86_64 - package containerd.io-1.4.3-3.1.el8.x86_64 conflicts with runc provided by runc-1.0.0-61.rc8.module+el8.1.0+5460+5d763c32.x86_64 - package containerd.io-1.4.3-3.1.el8.x86_64 obsoletes runc provided by runc-1.0.0-61.rc8.module+el8.1.0+5460+5d763c32.x86_64 - package containerd.io-1.4.3-3.1.el8.x86_64 conflicts with runc provided by runc-1.0.0-64.rc9.module+el8.1.1+5502+fbec5cc6.x86_64 - package containerd.io-1.4.3-3.1.el8.x86_64 obsoletes runc provided by runc-1.0.0-64.rc9.module+el8.1.1+5502+fbec5cc6.x86_64 - package containerd.io-1.4.3-3.1.el8.x86_64 conflicts with runc provided by runc-1.0.0-65.rc10.module+el8.2.0+5584+b2b2d3fb.x86_64 - package containerd.io-1.4.3-3.1.el8.x86_64 obsoletes runc provided by runc-1.0.0-65.rc10.module+el8.2.0+5584+b2b2d3fb.x86_64 - package containerd.io-1.4.3-3.1.el8.x86_64 conflicts with runc provided by runc-1.0.0-65.rc10.module+el8.2.0+7615+180dc822.x86_64 - package containerd.io-1.4.3-3.1.el8.x86_64 obsoletes runc provided by runc-1.0.0-65.rc10.module+el8.2.0+7615+180dc822.x86_64 - package containerd.io-1.4.3-3.1.el8.x86_64 conflicts with runc provided by runc-1.0.0-66.rc10.module+el8.2.1+7658+86e51d52.x86_64 - package containerd.io-1.4.3-3.1.el8.x86_64 obsoletes runc provided by runc-1.0.0-66.rc10.module+el8.2.1+7658+86e51d52.x86_64 - cannot install the best candidate for the job - package runc-1.0.0-55.rc5.dev.git2abd837.module+el8+5190+20ee9d65.x86_64 is filtered out by modular filtering - package runc-1.0.0-55.rc5.dev.git2abd837.module+el8.0.0+5214+b7869c3a.x86_64 is filtered out by modular filtering - package runc-1.0.0-55.rc5.dev.git2abd837.module+el8.0.0+5337+91623acb.x86_64 is filtered out by modular filtering - package runc-1.0.0-55.rc5.dev.git2abd837.module+el8.1.0+5440+42cffa37.x86_64 is filtered out by modular filtering - package runc-1.0.0-56.rc5.dev.git2abd837.module+el8.1.0+5459+24f6812a.x86_64 is filtered out by modular filtering - package runc-1.0.0-56.rc5.dev.git2abd837.module+el8.2.0+7621+b33f33e5.x86_64 is filtered out by modular filtering - package runc-1.0.0-64.rc10.module+el8.2.0+5585+88100286.x86_64 is filtered out by modular filtering - package runc-1.0.0-64.rc10.module+el8.2.0+7618+3a616245.x86_64 is filtered out by modular filtering - package runc-1.0.0-64.rc10.module+el8.3.0+7863+c7f8774f.x86_64 is filtered out by modular filtering - package runc-1.0.0-56.rc5.dev.git2abd837.module+el8.3.0+7864+d0e2eddf.x86_64 is filtered out by modular filtering - package runc-1.0.0-64.rc10.module+el8.3.0+9619+9eeb6ed6.x86_64 is filtered out by modular filtering 問題 2: problem with installed package buildah-1.15.1-2.0.1.module+el8.3.0+7866+f387f528.x86_64 - package buildah-1.15.1-2.0.1.module+el8.3.0+7866+f387f528.x86_64 requires runc >= 1.0.0-26, but none of the providers can be installed - package buildah-1.11.6-4.0.1.module+el8.1.1+5502+fbec5cc6.x86_64 requires runc >= 1.0.0-26, but none of the providers can be installed - package buildah-1.11.6-6.0.1.module+el8.1.1+5573+1c3f6079.x86_64 requires runc >= 1.0.0-26, but none of the providers can be installed - package buildah-1.11.6-7.0.1.module+el8.2.0+5584+b2b2d3fb.x86_64 requires runc >= 1.0.0-26, but none of the providers can be installed - package buildah-1.11.6-8.0.1.module+el8.2.0+7615+180dc822.x86_64 requires runc >= 1.0.0-26, but none of the providers can be installed - package buildah-1.11.6-8.0.2.module+el8.2.0+7622+50d25570.x86_64 requires runc >= 1.0.0-26, but none of the providers can be installed - package buildah-1.14.9-1.0.1.module+el8.2.1+7658+86e51d52.x86_64 requires runc >= 1.0.0-26, but none of the providers can be installed - package buildah-1.5-3.0.1.gite94b4f9.module+el8+5201+6423ecab.x86_64 requires runc >= 1.0.0-26, but none of the providers can be installed - package buildah-1.5-3.0.1.gite94b4f9.module+el8.0.0+5215+77f672ad.x86_64 requires runc >= 1.0.0-26, but none of the providers can be installed - package buildah-1.5-3.0.1.gite94b4f9.module+el8.0.0+5336+de35ffea.x86_64 requires runc >= 1.0.0-26, but none of the providers can be installed - package buildah-1.5-3.0.1.gite94b4f9.module+el8.0.0.z+5239+bd2c200f.x86_64 requires runc >= 1.0.0-26, but none of the providers can be installed - package buildah-1.9.0-5.0.1.module+el8.1.0+5440+994fc847.x86_64 requires runc >= 1.0.0-26, but none of the providers can be installed - package containerd.io-1.4.3-3.1.el8.x86_64 conflicts with runc provided by runc-1.0.0-68.rc92.module+el8.3.0+7866+f387f528.x86_64 - package containerd.io-1.4.3-3.1.el8.x86_64 obsoletes runc provided by runc-1.0.0-68.rc92.module+el8.3.0+7866+f387f528.x86_64 - package containerd.io-1.4.3-3.1.el8.x86_64 conflicts with runc provided by runc-1.0.0-54.rc5.dev.git2abd837.module+el8+5201+6423ecab.x86_64 - package containerd.io-1.4.3-3.1.el8.x86_64 obsoletes runc provided by runc-1.0.0-54.rc5.dev.git2abd837.module+el8+5201+6423ecab.x86_64 - package containerd.io-1.4.3-3.1.el8.x86_64 conflicts with runc provided by runc-1.0.0-55.rc5.dev.git2abd837.module+el8.0.0+5215+77f672ad.x86_64 - package containerd.io-1.4.3-3.1.el8.x86_64 obsoletes runc provided by runc-1.0.0-55.rc5.dev.git2abd837.module+el8.0.0+5215+77f672ad.x86_64 - package containerd.io-1.4.3-3.1.el8.x86_64 conflicts with runc provided by runc-1.0.0-55.rc5.dev.git2abd837.module+el8.0.0.z+5239+bd2c200f.x86_64 - package containerd.io-1.4.3-3.1.el8.x86_64 obsoletes runc provided by runc-1.0.0-55.rc5.dev.git2abd837.module+el8.0.0.z+5239+bd2c200f.x86_64 - package containerd.io-1.4.3-3.1.el8.x86_64 conflicts with runc provided by runc-1.0.0-56.rc8.dev.git425e105.module+el8.0.0+5336+de35ffea.x86_64 - package containerd.io-1.4.3-3.1.el8.x86_64 obsoletes runc provided by runc-1.0.0-56.rc8.dev.git425e105.module+el8.0.0+5336+de35ffea.x86_64 - package containerd.io-1.4.3-3.1.el8.x86_64 conflicts with runc provided by runc-1.0.0-60.rc8.module+el8.1.0+5440+994fc847.x86_64 - package containerd.io-1.4.3-3.1.el8.x86_64 obsoletes runc provided by runc-1.0.0-60.rc8.module+el8.1.0+5440+994fc847.x86_64 - package containerd.io-1.4.3-3.1.el8.x86_64 conflicts with runc provided by runc-1.0.0-61.rc8.module+el8.1.0+5460+5d763c32.x86_64 - package containerd.io-1.4.3-3.1.el8.x86_64 obsoletes runc provided by runc-1.0.0-61.rc8.module+el8.1.0+5460+5d763c32.x86_64 - package containerd.io-1.4.3-3.1.el8.x86_64 conflicts with runc provided by runc-1.0.0-64.rc9.module+el8.1.1+5502+fbec5cc6.x86_64 - package containerd.io-1.4.3-3.1.el8.x86_64 obsoletes runc provided by runc-1.0.0-64.rc9.module+el8.1.1+5502+fbec5cc6.x86_64 - package containerd.io-1.4.3-3.1.el8.x86_64 conflicts with runc provided by runc-1.0.0-65.rc10.module+el8.2.0+5584+b2b2d3fb.x86_64 - package containerd.io-1.4.3-3.1.el8.x86_64 obsoletes runc provided by runc-1.0.0-65.rc10.module+el8.2.0+5584+b2b2d3fb.x86_64 - package containerd.io-1.4.3-3.1.el8.x86_64 conflicts with runc provided by runc-1.0.0-65.rc10.module+el8.2.0+7615+180dc822.x86_64 - package containerd.io-1.4.3-3.1.el8.x86_64 obsoletes runc provided by runc-1.0.0-65.rc10.module+el8.2.0+7615+180dc822.x86_64 - package containerd.io-1.4.3-3.1.el8.x86_64 conflicts with runc provided by runc-1.0.0-66.rc10.module+el8.2.1+7658+86e51d52.x86_64 - package containerd.io-1.4.3-3.1.el8.x86_64 obsoletes runc provided by runc-1.0.0-66.rc10.module+el8.2.1+7658+86e51d52.x86_64 - package docker-ce-3:20.10.2-3.el8.x86_64 requires containerd.io >= 1.4.1, but none of the providers can be installed - cannot install the best candidate for the job - package runc-1.0.0-55.rc5.dev.git2abd837.module+el8+5190+20ee9d65.x86_64 is filtered out by modular filtering - package runc-1.0.0-55.rc5.dev.git2abd837.module+el8.0.0+5214+b7869c3a.x86_64 is filtered out by modular filtering - package runc-1.0.0-55.rc5.dev.git2abd837.module+el8.0.0+5337+91623acb.x86_64 is filtered out by modular filtering - package runc-1.0.0-55.rc5.dev.git2abd837.module+el8.1.0+5440+42cffa37.x86_64 is filtered out by modular filtering - package runc-1.0.0-56.rc5.dev.git2abd837.module+el8.1.0+5459+24f6812a.x86_64 is filtered out by modular filtering - package runc-1.0.0-56.rc5.dev.git2abd837.module+el8.2.0+7621+b33f33e5.x86_64 is filtered out by modular filtering - package runc-1.0.0-64.rc10.module+el8.2.0+5585+88100286.x86_64 is filtered out by modular filtering - package runc-1.0.0-64.rc10.module+el8.2.0+7618+3a616245.x86_64 is filtered out by modular filtering - package runc-1.0.0-64.rc10.module+el8.3.0+7863+c7f8774f.x86_64 is filtered out by modular filtering - package runc-1.0.0-56.rc5.dev.git2abd837.module+el8.3.0+7864+d0e2eddf.x86_64 is filtered out by modular filtering - package runc-1.0.0-64.rc10.module+el8.3.0+9619+9eeb6ed6.x86_64 is filtered out by modular filtering (競合するパッケージを置き換えるには、コマンドラインに '--allowerasing' を追加してみてください または、'--skip-broken' を追加して、インストール不可のパッケージをスキップしてください または、'--nobest' を追加して、最適候補のパッケージのみを使用しないでください)
Dockerをインストールしようとすると以下のエラーが出ました。
・問題 1: problem with installed package podman-2.0.5-5.0.1.module+el8.3.0+7866+f387f528.x86_64
・問題 2: problem with installed package buildah-1.15.1-2.0.1.module+el8.3.0+7866+f387f528.x86_64
「podman」と「buildah」がインストールされていると、「Docker」と競合してしまいエラーになっています。
参考サイト
今回は、エラーメッセージの指示に従い「--allowerasing」オプションを追加して、競合パッケージを置換することにしました。
docker-ceパッケージのインストール (「--allowerasing」オプションをつけて、競合するpodmanとbuildahを置換)
dnf install --allowerasing docker-ce docker-ce-cli containerd.io
[root@SV-TITAN ~]# dnf install --allowerasing docker-ce docker-ce-cli containerd.io メタデータの期限切れの最終確認: 0:03:57 時間前の 2021年01月11日 11時19分31秒 に実施しました。 依存関係が解決しました。 ==================================================================================================== パッケージ Arch バージョン リポジトリー サイズ ==================================================================================================== インストール: containerd.io x86_64 1.4.3-3.1.el8 docker-ce-stable 33 M 置き換え runc.x86_64 1.0.0-68.rc92.module+el8.3.0+7866+f387f528 docker-ce x86_64 3:20.10.2-3.el8 docker-ce-stable 27 M docker-ce-cli x86_64 1:20.10.2-3.el8 docker-ce-stable 33 M 依存関係のインストール: docker-ce-rootless-extras x86_64 20.10.2-3.el8 docker-ce-stable 9.1 M libcgroup x86_64 0.41-19.el8 ol8_baseos_latest 70 k 依存関係パッケージの削除: buildah x86_64 1.15.1-2.0.1.module+el8.3.0+7866+f387f528 @AppStream 28 M cockpit-podman noarch 18.1-2.module+el8.3.0+7866+f387f528 @AppStream 4.9 M podman x86_64 2.0.5-5.0.1.module+el8.3.0+7866+f387f528 @AppStream 51 M podman-catatonit x86_64 2.0.5-5.0.1.module+el8.3.0+7866+f387f528 @AppStream 752 k トランザクションの概要 ==================================================================================================== インストール 5 パッケージ 削除 4 パッケージ ダウンロードサイズの合計: 102 M これでよろしいですか? [y/N]: y
パッケージのダウンロード: (1/5): docker-ce-20.10.2-3.el8.x86_64.rpm 5.6 MB/s | 27 MB 00:04 (2/5): docker-ce-rootless-extras-20.10.2-3.el8.x86_64.rpm 5.7 MB/s | 9.1 MB 00:01 (3/5): libcgroup-0.41-19.el8.x86_64.rpm 37 kB/s | 70 kB 00:01 (4/5): containerd.io-1.4.3-3.1.el8.x86_64.rpm 3.0 MB/s | 33 MB 00:11 (5/5): docker-ce-cli-20.10.2-3.el8.x86_64.rpm 2.9 MB/s | 33 MB 00:11 ---------------------------------------------------------------------------------------------------- 合計 8.7 MB/s | 102 MB 00:11 警告: /var/cache/dnf/docker-ce-stable-fa9dc42ab4cec2f4/packages/containerd.io-1.4.3-3.1.el8.x86_64.rpm: ヘッダー V4 RSA/SHA512 Signature、鍵 ID 621e9f35: NOKEY Docker CE Stable - x86_64 26 kB/s | 1.6 kB 00:00 GPG 鍵 0x621E9F35 をインポート中: Userid : "Docker Release (CE rpm) <docker@docker.com>" Fingerprint: ●●●● ●●●● ●●●● ●●●● ●●●● ●●●● ●●●● ●●●● ●●●● ●●●● From : https://download.docker.com/linux/centos/gpg これでよろしいですか? [y/N]: y
鍵のインポートに成功しました トランザクションの確認を実行中 トランザクションの確認に成功しました。 トランザクションのテストを実行中 トランザクションのテストに成功しました。 トランザクションを実行中 準備 : 1/1 scriptletの実行中: libcgroup-0.41-19.el8.x86_64 1/1 scriptletの実行中: libcgroup-0.41-19.el8.x86_64 1/10 インストール : libcgroup-0.41-19.el8.x86_64 1/10 scriptletの実行中: libcgroup-0.41-19.el8.x86_64 1/10 インストール : docker-ce-cli-1:20.10.2-3.el8.x86_64 2/10 scriptletの実行中: docker-ce-cli-1:20.10.2-3.el8.x86_64 2/10 インストール : containerd.io-1.4.3-3.1.el8.x86_64 3/10 scriptletの実行中: containerd.io-1.4.3-3.1.el8.x86_64 3/10 インストール : docker-ce-rootless-extras-20.10.2-3.el8.x86_64 4/10 scriptletの実行中: docker-ce-rootless-extras-20.10.2-3.el8.x86_64 4/10 インストール : docker-ce-3:20.10.2-3.el8.x86_64 5/10 scriptletの実行中: docker-ce-3:20.10.2-3.el8.x86_64 5/10 削除 : cockpit-podman-18.1-2.module+el8.3.0+7866+f387f528.noarch 6/10 削除 : podman-2.0.5-5.0.1.module+el8.3.0+7866+f387f528.x86_64 7/10 scriptletの実行中: podman-2.0.5-5.0.1.module+el8.3.0+7866+f387f528.x86_64 7/10 削除 : buildah-1.15.1-2.0.1.module+el8.3.0+7866+f387f528.x86_64 8/10 削除 : podman-catatonit-2.0.5-5.0.1.module+el8.3.0+7866+f387f528.x86_64 9/10 廃止 : runc-1.0.0-68.rc92.module+el8.3.0+7866+f387f528.x86_64 10/10 scriptletの実行中: runc-1.0.0-68.rc92.module+el8.3.0+7866+f387f528.x86_64 10/10 検証 : containerd.io-1.4.3-3.1.el8.x86_64 1/10 検証 : runc-1.0.0-68.rc92.module+el8.3.0+7866+f387f528.x86_64 2/10 検証 : docker-ce-3:20.10.2-3.el8.x86_64 3/10 検証 : docker-ce-cli-1:20.10.2-3.el8.x86_64 4/10 検証 : docker-ce-rootless-extras-20.10.2-3.el8.x86_64 5/10 検証 : libcgroup-0.41-19.el8.x86_64 6/10 検証 : buildah-1.15.1-2.0.1.module+el8.3.0+7866+f387f528.x86_64 7/10 検証 : cockpit-podman-18.1-2.module+el8.3.0+7866+f387f528.noarch 8/10 検証 : podman-2.0.5-5.0.1.module+el8.3.0+7866+f387f528.x86_64 9/10 検証 : podman-catatonit-2.0.5-5.0.1.module+el8.3.0+7866+f387f528.x86_64 10/10 インストール済み: containerd.io-1.4.3-3.1.el8.x86_64 docker-ce-3:20.10.2-3.el8.x86_64 docker-ce-cli-1:20.10.2-3.el8.x86_64 docker-ce-rootless-extras-20.10.2-3.el8.x86_64 libcgroup-0.41-19.el8.x86_64 削除しました: buildah-1.15.1-2.0.1.module+el8.3.0+7866+f387f528.x86_64 cockpit-podman-18.1-2.module+el8.3.0+7866+f387f528.noarch podman-2.0.5-5.0.1.module+el8.3.0+7866+f387f528.x86_64 podman-catatonit-2.0.5-5.0.1.module+el8.3.0+7866+f387f528.x86_64 完了しました!
インストール後の確認
dnf list installed | grep docker-ce
[root@SV-TITAN ~]# dnf list installed | grep docker-ce containerd.io.x86_64 1.4.3-3.1.el8 @docker-ce-stable docker-ce.x86_64 3:20.10.2-3.el8 @docker-ce-stable docker-ce-cli.x86_64 1:20.10.2-3.el8 @docker-ce-stable docker-ce-rootless-extras.x86_64 20.10.2-3.el8 @docker-ce-stable
which docker
[root@SV-TITAN ~]# which docker /usr/bin/docker
手順④:dockerdの起動および自動起動の設定
dockerの起動
systemctl start docker
systemctl status docker
[root@SV-TITAN ~]# systemctl start docker [root@SV-TITAN ~]# 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 Mon 2021-01-11 11:27:07 JST; 20s ago Docs: https://docs.docker.com Main PID: 7199 (dockerd) Tasks: 8 Memory: 150.3M CGroup: /system.slice/docker.service mq7199 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock 1月 11 11:26:54 SV-TITAN dockerd[7199]: time="2021-01-11T11:26:54.927785392+09:00" level=warning m> 1月 11 11:26:54 SV-TITAN dockerd[7199]: time="2021-01-11T11:26:54.927982293+09:00" level=info msg=> 1月 11 11:27:04 SV-TITAN dockerd[7199]: time="2021-01-11T11:27:04.280027482+09:00" level=info msg=> 1月 11 11:27:04 SV-TITAN dockerd[7199]: time="2021-01-11T11:27:04.444727396+09:00" level=info msg=> 1月 11 11:27:05 SV-TITAN dockerd[7199]: time="2021-01-11T11:27:05.459130183+09:00" level=info msg=> 1月 11 11:27:06 SV-TITAN dockerd[7199]: time="2021-01-11T11:27:06.494964156+09:00" level=warning m> 1月 11 11:27:06 SV-TITAN dockerd[7199]: time="2021-01-11T11:27:06.495344065+09:00" level=info msg=> 1月 11 11:27:06 SV-TITAN dockerd[7199]: time="2021-01-11T11:27:06.495468033+09:00" level=info msg=> 1月 11 11:27:07 SV-TITAN systemd[1]: Started Docker Application Container Engine. 1月 11 11:27:07 SV-TITAN dockerd[7199]: time="2021-01-11T11:27:07.542605113+09:00" level=info msg=>
dokerdプロセス確認
ps -aux | grep dockerd
[root@SV-TITAN ~]# ps -aux | grep dockerd root 7199 0.1 13.3 784384 94564 ? Ssl 11:26 0:00 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock root 7339 0.0 0.1 10280 1112 pts/0 S+ 11:28 0:00 grep --color=auto dockerd
dockerdの自動起動の設定
systemctl enable docker
systemctl is-enabled docker
[root@SV-TITAN ~]# systemctl enable docker Created symlink /etc/systemd/system/multi-user.target.wants/docker.service → /usr/lib/systemd/system/docker.service. [root@SV-TITAN ~]# systemctl is-enabled docker enabled
手順⑤:Dockerの動作確認
dockerバージョンの確認
docker --version
[root@SV-TITAN ~]# docker --version Docker version 20.10.2, build 2291f61
docker環境の情報を確認
docker info
[root@SV-TITAN ~]# docker info Client: Context: default Debug Mode: false Plugins: app: Docker App (Docker Inc., v0.9.1-beta3) buildx: Build with BuildKit (Docker Inc., v0.5.1-docker) Server: Containers: 0 Running: 0 Paused: 0 Stopped: 0 Images: 0 Server Version: 20.10.2 Storage Driver: overlay2 Backing Filesystem: xfs Supports d_type: true Native Overlay Diff: false Logging Driver: json-file Cgroup Driver: cgroupfs Cgroup Version: 1 Plugins: Volume: local Network: bridge host ipvlan macvlan null overlay Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog Swarm: inactive Runtimes: io.containerd.runc.v2 io.containerd.runtime.v1.linux runc Default Runtime: runc Init Binary: docker-init containerd version: 269548fa27e0089a8b8278fc4fc781d7f65a939b runc version: ff819c7e9184c13b7c2607fe6c30ae19403a7aff init version: de40ad0 Security Options: seccomp Profile: default Kernel Version: 5.4.17-2036.101.2.el8uek.x86_64 Operating System: Oracle Linux Server 8.3 OSType: linux Architecture: x86_64 CPUs: 1 Total Memory: 691.1MiB Name: SV-TITAN ID: 2YZ5:FHSS:FIFF:UWSC:TFQ7:3BEC:CETP:DMNH:VVY6:QMLA:ENTH:6HPL Docker Root Dir: /var/lib/docker Debug Mode: false Registry: https://index.docker.io/v1/ Labels: Experimental: false Insecure Registries: 127.0.0.0/8 Live Restore Enabled: false WARNING: No blkio weight support WARNING: No blkio weight_device support
コンテナ作成実行の簡易テスト
Dockerの基本コマンドを一通り使ってみる
さらにDockerについて勉強したい方におすすめの書籍
プログラマのためのDocker教科書 第2版 インフラの基礎知識&コードによる環境構築の自動化 |
インフラ基礎知識+インフラ環境構築の入門書の決定版!
「Linuxのコンテナ仮想化ツールであるDockerを使って、コードでインフラ環境を構築するための入門書」として好評を博した前著の改訂版です。
開発環境や実行環境などインフラ構築「自動化」の経験がない開発者を対象に、おさえておきたいシステム基盤&インフラの基礎知識に加えて、Dockerによるインフラ構築と管理の方法をやさしく解説します。
理解しにくいネットワークや仮想技術などのインフラの基礎概念を図解しながら、開発/実行環境を実際に構築することで、構成管理ツールを使ったインフラ構築の流れを解説していきます。
改訂にあたって、Dockerの新機能/コマンドに対応したほか、マルチホスト環境での実行環境構築をクラウドマネージドサービスを使うように変更。
よりプログラマが注力すべきところにページを割き、Webエンジニアや機械学習エンジニアの環境構築に利用できる具体例を解説しています。
インフラエンジニアの勉強ができるオンライン学習サイト
Udemy (オンライン動画学習サイト)
Udemy(ユーデミー)は、オンラインで動画で学習できるサービスです。
ITエンジニア系の講座もたくさん公開されています。
Udemyの特徴
- ユーザー登録すれば、第1回の講座は無料で視聴できる
- 無料のコンテンツもある
- 過去に受講した人の人数や、受講した人の評価も表示されるので選びやすい