Ubuntu 22.04に最新版Dockerをインストール

WEB

Dockerのインストール

apt install docker ではVersion: 1.5-2という非常に古い(2015年)ものしか入らないため、Dockerの公式がリポジトリを追加して最新版のDockerをインストールした。

$ sudo apt-get update 
$ sudo apt-get install apt-transport-https ca-certificates curl gnupg lsb-release
$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
$ echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
$ sudo apt-get update

確認

hbirds@hbirds-Lenovo-G580:~$ sudo apt info docker-ce
Package: docker-ce
Version: 5:20.10.23~3-0~ubuntu-jammy
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-compose-plugin

docker run hello-world で動作確認。以下のようなメッセージを確認できたら、Dockerは問題なく動作確している。

hbirds@hbirds-Lenovo-G580:~$ sudo docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
2db29710123e: Pull complete 
Digest: sha256:aa0cc8055b82dc2509bed2e19b275c8f463506616377219d9642221ab53cf9fe
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 Composeのインストール

Githubのサイトで最新版がv2.15.1なのを確認

$ sudo curl -L https://github.com/docker/compose/releases/download/v2.15.1/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose

$ sudo chmod +x /usr/local/bin/docker-compose

ちゃんとインストールできたか確認

$ sudo docker-compose --version
Docker Compose version v2.15.1
Copied title and URL