Uncategorized

Ubuntuに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=amd64 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

sudo apt-get install docker-ce docker-ce-cli containerd.io

sudo curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose

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

ログ:

Welcome to Ubuntu 20.04.2 LTS (GNU/Linux 5.8.0-1031-oracle x86_64)

 * Documentation:  https://help.ubuntu.com
 * Management:     https://landscape.canonical.com
 * Support:        https://ubuntu.com/advantage


This system has been minimized by removing packages and content that are
not required on a system that users do not log into.

To restore this content, you can run the 'unminimize' command.

0 updates can be applied immediately.


The list of available updates is more than a week old.
To check for new updates run: sudo apt update

The programs included with the Ubuntu system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Ubuntu comes with ABSOLUTELY NO WARRANTY, to the extent permitted by
applicable law.

To run a command as administrator (user "root"), use "sudo ".
See "man sudo_root" for details.

ubuntu@instance-20210719-1118:~$ sudo apt-get remove docker docker-engine docker.io containerd runc
Reading package lists... Done
Building dependency tree       
Reading state information... Done

No apt package "docker", but there is a snap with that name.
Try "snap install docker"

E: Unable to locate package docker
E: Unable to locate package docker-engine
E: Unable to locate package docker.io
E: Couldn't find any package by glob 'docker.io'
E: Couldn't find any package by regex 'docker.io'
E: Unable to locate package containerd
E: Unable to locate package runc
ubuntu@instance-20210719-1118:~$ sudo apt-get update
Get:1 http://security.ubuntu.com/ubuntu focal-security InRelease [114 kB]
Get:2 http://ap-tokyo-1-ad-1.clouds.archive.ubuntu.com/ubuntu focal InRelease [265 kB]
Get:3 http://security.ubuntu.com/ubuntu focal-security/main amd64 Packages [745 kB]
Get:4 http://ap-tokyo-1-ad-1.clouds.archive.ubuntu.com/ubuntu focal-updates InRelease [114 kB]
Get:5 http://ap-tokyo-1-ad-1.clouds.archive.ubuntu.com/ubuntu focal-backports InRelease [101 kB]
Get:6 http://security.ubuntu.com/ubuntu focal-security/main Translation-en [148 kB]
Get:7 http://security.ubuntu.com/ubuntu focal-security/restricted amd64 Packages [282 kB]
Get:8 http://security.ubuntu.com/ubuntu focal-security/restricted Translation-en [40.9 kB]
Get:9 http://security.ubuntu.com/ubuntu focal-security/universe amd64 Packages [632 kB]
Get:10 http://ap-tokyo-1-ad-1.clouds.archive.ubuntu.com/ubuntu focal/main amd64 Packages [970 kB]
Get:11 http://security.ubuntu.com/ubuntu focal-security/universe Translation-en [97.2 kB]
Get:12 http://security.ubuntu.com/ubuntu focal-security/multiverse amd64 Packages [19.9 kB]    
Get:13 http://security.ubuntu.com/ubuntu focal-security/multiverse Translation-en [4316 B]     
Get:14 http://ap-tokyo-1-ad-1.clouds.archive.ubuntu.com/ubuntu focal/main Translation-en [506 kB]
Get:15 http://ap-tokyo-1-ad-1.clouds.archive.ubuntu.com/ubuntu focal/restricted amd64 Packages [22.0 kB]
Get:16 http://ap-tokyo-1-ad-1.clouds.archive.ubuntu.com/ubuntu focal/restricted Translation-en [6212 B]
Get:17 http://ap-tokyo-1-ad-1.clouds.archive.ubuntu.com/ubuntu focal/universe amd64 Packages [8628 kB]
Get:18 http://ap-tokyo-1-ad-1.clouds.archive.ubuntu.com/ubuntu focal/universe Translation-en [5124 kB]
Get:19 http://ap-tokyo-1-ad-1.clouds.archive.ubuntu.com/ubuntu focal/multiverse amd64 Packages [144 kB]
Get:20 http://ap-tokyo-1-ad-1.clouds.archive.ubuntu.com/ubuntu focal/multiverse Translation-en [104 kB]
Get:21 http://ap-tokyo-1-ad-1.clouds.archive.ubuntu.com/ubuntu focal-updates/main amd64 Packages [1086 kB]
Get:22 http://ap-tokyo-1-ad-1.clouds.archive.ubuntu.com/ubuntu focal-updates/main Translation-en [239 kB]
Get:23 http://ap-tokyo-1-ad-1.clouds.archive.ubuntu.com/ubuntu focal-updates/restricted amd64 Packages [318 kB]
Get:24 http://ap-tokyo-1-ad-1.clouds.archive.ubuntu.com/ubuntu focal-updates/restricted Translation-en [46.1 kB]
Get:25 http://ap-tokyo-1-ad-1.clouds.archive.ubuntu.com/ubuntu focal-updates/universe amd64 Packages [841 kB]
Get:26 http://ap-tokyo-1-ad-1.clouds.archive.ubuntu.com/ubuntu focal-updates/universe Translation-en [176 kB]
Get:27 http://ap-tokyo-1-ad-1.clouds.archive.ubuntu.com/ubuntu focal-updates/multiverse amd64 Packages [23.6 kB]
Get:28 http://ap-tokyo-1-ad-1.clouds.archive.ubuntu.com/ubuntu focal-updates/multiverse Translation-en [6472 B]
Get:29 http://ap-tokyo-1-ad-1.clouds.archive.ubuntu.com/ubuntu focal-backports/main amd64 Packages [2568 B]
Get:30 http://ap-tokyo-1-ad-1.clouds.archive.ubuntu.com/ubuntu focal-backports/main Translation-en [1120 B]
Get:31 http://ap-tokyo-1-ad-1.clouds.archive.ubuntu.com/ubuntu focal-backports/universe amd64 Packages [5792 B]
Get:32 http://ap-tokyo-1-ad-1.clouds.archive.ubuntu.com/ubuntu focal-backports/universe Translation-en [2060 B]
Fetched 20.8 MB in 10s (2029 kB/s)                                                                                                                              
Reading package lists... Done
ubuntu@instance-20210719-1118:~$ sudo apt-get install \
>     apt-transport-https \
>     ca-certificates \
>     curl \
>     gnupg \
>     lsb-release
Reading package lists... Done
Building dependency tree       
Reading state information... Done
lsb-release is already the newest version (11.1.0ubuntu2).
lsb-release set to manually installed.
ca-certificates is already the newest version (20210119~20.04.1).
ca-certificates set to manually installed.
curl is already the newest version (7.68.0-1ubuntu2.5).
gnupg is already the newest version (2.2.19-3ubuntu2.1).
The following NEW packages will be installed:
  apt-transport-https
0 upgraded, 1 newly installed, 0 to remove and 32 not upgraded.
Need to get 4680 B of archives.
After this operation, 162 kB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://ap-tokyo-1-ad-1.clouds.archive.ubuntu.com/ubuntu focal-updates/universe amd64 apt-transport-https all 2.0.6 [4680 B]
Fetched 4680 B in 0s (10.9 kB/s)
debconf: delaying package configuration, since apt-utils is not installed
Selecting previously unselected package apt-transport-https.
(Reading database ... 55047 files and directories currently installed.)
Preparing to unpack .../apt-transport-https_2.0.6_all.deb ...
Unpacking apt-transport-https (2.0.6) ...
Setting up apt-transport-https (2.0.6) ...
ubuntu@instance-20210719-1118:~$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
ubuntu@instance-20210719-1118:~$ echo \
>   "deb [arch=amd64 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
ubuntu@instance-20210719-1118:~$  sudo apt-get update
Get:1 https://download.docker.com/linux/ubuntu focal InRelease [52.1 kB]
Get:2 https://download.docker.com/linux/ubuntu focal/stable amd64 Packages [9960 B]                                                                         
Hit:3 http://security.ubuntu.com/ubuntu focal-security InRelease     
Hit:4 http://ap-tokyo-1-ad-1.clouds.archive.ubuntu.com/ubuntu focal InRelease
Hit:5 http://ap-tokyo-1-ad-1.clouds.archive.ubuntu.com/ubuntu focal-updates InRelease
Hit:6 http://ap-tokyo-1-ad-1.clouds.archive.ubuntu.com/ubuntu focal-backports InRelease
Fetched 62.1 kB in 1s (55.4 kB/s)
Reading package lists... Done
ubuntu@instance-20210719-1118:~$ sudo apt-get update
Hit:1 https://download.docker.com/linux/ubuntu focal InRelease
0% [Connecting to ap-tokyo-1-ad-1.clouds.archive.ubuntu.com (91.189.88.245)] [Connecting to security.ubuntu.com (91.189.91.39)]
Hit:2 http://security.ubuntu.com/ubuntu focal-security InRelease                                                               
Hit:3 http://ap-tokyo-1-ad-1.clouds.archive.ubuntu.com/ubuntu focal InRelease                     
Hit:4 http://ap-tokyo-1-ad-1.clouds.archive.ubuntu.com/ubuntu focal-updates InRelease
Hit:5 http://ap-tokyo-1-ad-1.clouds.archive.ubuntu.com/ubuntu focal-backports InRelease
Reading package lists... Done
ubuntu@instance-20210719-1118:~$  sudo apt-get install docker-ce docker-ce-cli containerd.io
Reading package lists... Done
Building dependency tree... 50%
Building dependency tree       
Reading state information... Done
The following additional packages will be installed:
  docker-ce-rootless-extras docker-scan-plugin git git-man less libcurl3-gnutls liberror-perl libltdl7 pigz slirp4netns
Suggested packages:
  aufs-tools cgroupfs-mount | cgroup-lite git-daemon-run | git-daemon-sysvinit git-doc git-el git-email git-gui gitk gitweb git-cvs git-mediawiki git-svn
The following NEW packages will be installed:
  containerd.io docker-ce docker-ce-cli docker-ce-rootless-extras docker-scan-plugin git git-man less libcurl3-gnutls liberror-perl libltdl7 pigz slirp4netns
0 upgraded, 13 newly installed, 0 to remove and 32 not upgraded.
Need to get 113 MB of archives.
After this operation, 506 MB of additional disk space will be used.
Get:1 https://download.docker.com/linux/ubuntu focal/stable amd64 containerd.io amd64 1.4.6-1 [28.3 MB]
Get:2 http://ap-tokyo-1-ad-1.clouds.archive.ubuntu.com/ubuntu focal/universe amd64 pigz amd64 2.4-1 [57.4 kB]
Get:3 http://ap-tokyo-1-ad-1.clouds.archive.ubuntu.com/ubuntu focal-updates/main amd64 less amd64 551-1ubuntu0.1 [123 kB]
Get:4 http://ap-tokyo-1-ad-1.clouds.archive.ubuntu.com/ubuntu focal-updates/main amd64 libcurl3-gnutls amd64 7.68.0-1ubuntu2.5 [232 kB]
Get:5 https://download.docker.com/linux/ubuntu focal/stable amd64 docker-ce-cli amd64 5:20.10.7~3-0~ubuntu-focal [41.4 MB]
Get:6 http://ap-tokyo-1-ad-1.clouds.archive.ubuntu.com/ubuntu focal/main amd64 liberror-perl all 0.17029-1 [26.5 kB]                                            
Get:7 http://ap-tokyo-1-ad-1.clouds.archive.ubuntu.com/ubuntu focal-updates/main amd64 git-man all 1:2.25.1-1ubuntu3.1 [884 kB]                                 
Get:8 http://ap-tokyo-1-ad-1.clouds.archive.ubuntu.com/ubuntu focal-updates/main amd64 git amd64 1:2.25.1-1ubuntu3.1 [4557 kB]                                  
Get:9 https://download.docker.com/linux/ubuntu focal/stable amd64 docker-ce amd64 5:20.10.7~3-0~ubuntu-focal [24.8 MB]                                          
Get:10 https://download.docker.com/linux/ubuntu focal/stable amd64 docker-ce-rootless-extras amd64 5:20.10.7~3-0~ubuntu-focal [9063 kB]                         
Get:11 https://download.docker.com/linux/ubuntu focal/stable amd64 docker-scan-plugin amd64 0.8.0~ubuntu-focal [3889 kB]                                        
Get:12 http://ap-tokyo-1-ad-1.clouds.archive.ubuntu.com/ubuntu focal/main amd64 libltdl7 amd64 2.4.6-14 [38.5 kB]                                               
Get:13 http://ap-tokyo-1-ad-1.clouds.archive.ubuntu.com/ubuntu focal/universe amd64 slirp4netns amd64 0.4.3-1 [74.3 kB]                                         
Fetched 113 MB in 21s (5362 kB/s)                                                                                                                               
debconf: delaying package configuration, since apt-utils is not installed
Selecting previously unselected package pigz.
(Reading database ... 55051 files and directories currently installed.)
Preparing to unpack .../00-pigz_2.4-1_amd64.deb ...
Unpacking pigz (2.4-1) ...
Selecting previously unselected package less.
Preparing to unpack .../01-less_551-1ubuntu0.1_amd64.deb ...
Unpacking less (551-1ubuntu0.1) ...
Selecting previously unselected package containerd.io.
Preparing to unpack .../02-containerd.io_1.4.6-1_amd64.deb ...
Unpacking containerd.io (1.4.6-1) ...
Selecting previously unselected package docker-ce-cli.
Preparing to unpack .../03-docker-ce-cli_5%3a20.10.7~3-0~ubuntu-focal_amd64.deb ...
Unpacking docker-ce-cli (5:20.10.7~3-0~ubuntu-focal) ...
Selecting previously unselected package docker-ce.
Preparing to unpack .../04-docker-ce_5%3a20.10.7~3-0~ubuntu-focal_amd64.deb ...
Unpacking docker-ce (5:20.10.7~3-0~ubuntu-focal) ...
Selecting previously unselected package docker-ce-rootless-extras.
Preparing to unpack .../05-docker-ce-rootless-extras_5%3a20.10.7~3-0~ubuntu-focal_amd64.deb ...
Unpacking docker-ce-rootless-extras (5:20.10.7~3-0~ubuntu-focal) ...
Selecting previously unselected package docker-scan-plugin.
Preparing to unpack .../06-docker-scan-plugin_0.8.0~ubuntu-focal_amd64.deb ...
Unpacking docker-scan-plugin (0.8.0~ubuntu-focal) ...
Selecting previously unselected package libcurl3-gnutls:amd64.
Preparing to unpack .../07-libcurl3-gnutls_7.68.0-1ubuntu2.5_amd64.deb ...
Unpacking libcurl3-gnutls:amd64 (7.68.0-1ubuntu2.5) ...
Selecting previously unselected package liberror-perl.
Preparing to unpack .../08-liberror-perl_0.17029-1_all.deb ...
Unpacking liberror-perl (0.17029-1) ...
Selecting previously unselected package git-man.
Preparing to unpack .../09-git-man_1%3a2.25.1-1ubuntu3.1_all.deb ...
Unpacking git-man (1:2.25.1-1ubuntu3.1) ...
Selecting previously unselected package git.
Preparing to unpack .../10-git_1%3a2.25.1-1ubuntu3.1_amd64.deb ...
Unpacking git (1:2.25.1-1ubuntu3.1) ...
Selecting previously unselected package libltdl7:amd64.
Preparing to unpack .../11-libltdl7_2.4.6-14_amd64.deb ...
Unpacking libltdl7:amd64 (2.4.6-14) ...
Selecting previously unselected package slirp4netns.
Preparing to unpack .../12-slirp4netns_0.4.3-1_amd64.deb ...
Unpacking slirp4netns (0.4.3-1) ...
Setting up slirp4netns (0.4.3-1) ...
Setting up docker-scan-plugin (0.8.0~ubuntu-focal) ...
Setting up less (551-1ubuntu0.1) ...
Setting up libcurl3-gnutls:amd64 (7.68.0-1ubuntu2.5) ...
Setting up liberror-perl (0.17029-1) ...
Setting up containerd.io (1.4.6-1) ...
Created symlink /etc/systemd/system/multi-user.target.wants/containerd.service → /lib/systemd/system/containerd.service.
Setting up libltdl7:amd64 (2.4.6-14) ...
Setting up docker-ce-cli (5:20.10.7~3-0~ubuntu-focal) ...
Setting up pigz (2.4-1) ...
Setting up git-man (1:2.25.1-1ubuntu3.1) ...
Setting up docker-ce-rootless-extras (5:20.10.7~3-0~ubuntu-focal) ...
Setting up docker-ce (5:20.10.7~3-0~ubuntu-focal) ...
Created symlink /etc/systemd/system/multi-user.target.wants/docker.service → /lib/systemd/system/docker.service.
Created symlink /etc/systemd/system/sockets.target.wants/docker.socket → /lib/systemd/system/docker.socket.
Setting up git (1:2.25.1-1ubuntu3.1) ...
Processing triggers for libc-bin (2.31-0ubuntu9.2) ...
Processing triggers for systemd (245.4-4ubuntu3.6) ...
Processing triggers for mime-support (3.64ubuntu1) ...
ubuntu@instance-20210719-1118:~$ docker ps
Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Get http://%2Fvar%2Frun%2Fdocker.sock/v1.24/containers/json: dial unix /var/run/docker.sock: connect: permission denied
ubuntu@instance-20210719-1118:~$ sudo docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
b8dfde127a29: Pull complete 
Digest: sha256:df5f5184104426b65967e016ff2ac0bfcd44ad7899ca3bbcf8e44e4461491a9e
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/

$ sudo curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   633  100   633    0     0   1148      0 --:--:-- --:--:-- --:--:--  1146
100 12.1M  100 12.1M    0     0   207k      0  0:01:00  0:01:00 --:--:--  157k
ubuntu@instance-20210719-1118:~$ sudo chmod +x /usr/local/bin/docker-compose