UbuntuにDockerをインストールするまで
環境
OS | Ubuntu 18.04.3 LTS |
Docker | 19.03.12 |
手順
既にインストールされているDockerは削除する
1 |
$ sudo apt-get remove docker docker-engine docker.io containerd runc |
パッケージ情報を更新する
1 |
$ sudo apt-get update |
Dockerのリポジトリをインストールするためのパッケージをインストールする
1 |
$ sudo apt-get install -y apt-transport-https ca-certificates curl gunpg-agent software-properties-common |
Dockerのパッケージの署名を検証するための、GPG鍵を追加する
1 |
$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - |
鍵があるか確かめる
1 2 3 |
$ apt-key list | grep docker Warning: apt-key output should not be parsed (stdout is not a terminal) uid [ 不明 ] Docker Release (CE deb) <docker@docker.com> |
Ubuntuがamd64(x86_64)用のリポジトリを追加する
1 |
$ sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" |
Dockerをインストールする
1 2 |
$ sudo apt-get update $ sudo apt-get install -y docker-ce docker-ce-cli containerd.io |
Dockerのバージョンを確認する
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
$ sudo docker version Client: Docker Engine - Community Version: 19.03.12 API version: 1.40 Go version: go1.13.10 Git commit: 48a66213fe Built: Mon Jun 22 15:45:36 2020 OS/Arch: linux/amd64 Experimental: false Server: Docker Engine - Community Engine: Version: 19.03.12 API version: 1.40 (minimum version 1.12) Go version: go1.13.10 Git commit: 48a66213fe Built: Mon Jun 22 15:44:07 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 |
Dockerが実行できるかテスト
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
$ sudo docker run hello-world 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/ |