1. はじめに
Dockerをインストールするにあたり、インターネットに接続できる環境での説明をします。
2. 動作環境
CentOS7.7
ベース環境 :サーバー(GUI使用)
選択した環境のアドオン :開発ツール
Docker :19.03.8 Community Edition 2020/3/26 時点の最新版
3.古いDockerがインストールされていないことを確認する
以下のコマンドで、dockderがインストールされていないことを確認します。
# yum list installed | grep docekr
※下記のいずれかが見つかれば、削除します。
docker
docker-client
docker-client-latest
docker-common
docker-latest
docker-latest-logrotate
docker-logrotate
docker-engine
# yum remove (削除するモジュール名) ....
4.Dockerのリポジトリを登録する
Dockerのインストール元のリポジトリを登録します。
# yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
5.Dockerのインストール
下記のコマンドでDockerをインストールします。
# yum install docker-ce
上記により、同時に以下もインストールされます。
containerd.io
docker-ce-cli
また、dockerのものではありませんが、container-selinux がインストールされていなければ、インストールされます。
6.動作テスト
バージョン確認をします。
Dockerを起動します。
```bash
# systemctl start docker
インストールバージョンを確認します。
# docker version
Client: Docker Engine - Community
Version: 19.03.8
API version: 1.40
Go version: go1.12.17
Git commit: afacb8b
Built: Wed Mar 11 01:27:04 2020
OS/Arch: linux/amd64
Experimental: false
Server: Docker Engine - Community
Engine:
Version: 19.03.8
API version: 1.40 (minimum version 1.12)
Go version: go1.12.17
Git commit: afacb8b
Built: Wed Mar 11 01:25:42 2020
OS/Arch: linux/amd64
Experimental: false
containerd:
Version: 1.2.13
GitCommit: 7ad184331fa3e55e52b890ea95e65ba581ae3429
runc:
Version: 1.0.0-rc10
GitCommit: dc9208a3303feef5b3839f4323d9beb36df0a9dd
docker-init:
Version: 0.18.0
GitCommit: fec3683
hello world を実行します。
初回の実行は、hello-worldがローカルにいないため、ダウンロードしてきます。(2~6行目)
7行目の Hello from Docker! 以降が表示されれば、正常に動作しています。
# docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
1b930d010525: Pull complete
Digest: sha256:f9dfddf63636d84ef479d645ab5885156ae030f611a56f3a7ac7f2fdd86d7e4e
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/
Dockerを停止します。
# systemctl stop docker
以上でDockerのインストールと動作テストが完了しました。