Ubuntu 20 に Docker をインストールする
既に作成済みの Ubuntu 20 (ESXi 6.7u1 VM) を docker ホストとして,Docker 公式ページの手順に従ってインストールしていく
- Install Docker Engine on Ubuntu | Docker Documentation
- Post-installation steps for Linux | Docker Documentation
Ubuntu VM 確認
$ uname -a Linux vm-ubuntu20-01 5.4.0-125-generic #141-Ubuntu SMP Wed Aug 10 13:42:03 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
既存パッケージの更新
$ sudo apt-get update $ sudo apt-get upgrade
必要なパッケージの追加
$ sudo apt-get install ca-certificates curl gnupg lsb-release
Docker の公式 GPG キーを追加
$ sudo mkdir -p /etc/apt/keyrings $ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
Docker リポジトリ情報の追加
$ echo \ "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \ $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
リポジトリから Docker インストール
$ sudo apt-get update $ sudo apt-get install docker-ce docker-ce-cli containerd.io docker-compose-plugin
インストール確認
$ sudo docker run hello-world
正常にインストールされたように見える.
Unable to find image 'hello-world:latest' locally latest: Pulling from library/hello-world 2db29710123e: Pull complete Digest: sha256:62af9efd515a25f84961b70f973a798d2eca956b1b2b026d0a4a63a3b0b6a3f2 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/
自動起動の確認
$ systemctl status docker
● docker.service - Docker Application Container Engine Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled) Active: active (running) since Sat 2022-09-17 08:21:07 UTC; 45min ago TriggeredBy: ● docker.socket Docs: https://docs.docker.com Main PID: 953 (dockerd) Tasks: 9 Memory: 95.4M CGroup: /system.slice/docker.service mq953 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock
$ systemctl status containerd
● containerd.service - containerd container runtime Loaded: loaded (/lib/systemd/system/containerd.service; enabled; vendor preset: enabled) Active: active (running) since Sat 2022-09-17 08:21:05 UTC; 52min ago Docs: https://containerd.io Process: 836 ExecStartPre=/sbin/modprobe overlay (code=exited, status=0/SUCCESS) Main PID: 875 (containerd) Tasks: 8 Memory: 77.5M CGroup: /system.slice/containerd.service mq875 /usr/bin/containerd