Featured image of post 在 Ubuntu 20.04 Focal Fossa 上安裝 Docker

在 Ubuntu 20.04 Focal Fossa 上安裝 Docker

Ubuntu 20.04 在 4 月 23 日正式發行,發行版代號為 Focal Fossa,Linux Kernel 為 5.4。這次除了在安全性與性能上再次提升外,在檔案系統的部分,這次原生支援了 exFAT,並改善 ZFS 檔案系統的相容性。

現在使用 container 的需求量很大,安裝完後的第一件事情就是馬上來裝個 Docker,follow 官方的標準安裝流程:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
sudo apt-get remove -y docker docker-engine docker.io containerd runc; \
sudo apt-get update && \
sudo apt-get install -y apt-transport-https ca-certificates curl gnupg-agent software-properties-common && \
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - && \
sudo add-apt-repository \
   "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
   $(lsb_release -cs) \
   stable" && \
sudo apt-get update && \
sudo apt-get install -y docker-ce docker-ce-cli containerd.io

這時候問題來了,做到 add-apt-repository 這段的時候會出錯:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
Hit:1 http://tw.archive.ubuntu.com/ubuntu focal InRelease
Hit:2 http://tw.archive.ubuntu.com/ubuntu focal-updates InRelease
Hit:3 http://tw.archive.ubuntu.com/ubuntu focal-backports InRelease
Hit:4 http://tw.archive.ubuntu.com/ubuntu focal-security InRelease
Ign:5 https://download.docker.com/linux/ubuntu focal InRelease
Err:6 https://download.docker.com/linux/ubuntu focal Release
  404  Not Found [IP: 13.35.153.117 443]
Reading package lists... Done
E: The repository 'https://download.docker.com/linux/ubuntu focal Release' does not have a Release file.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.

為什麼呢?因為 20.04 才剛發布,Docker repository 還沒這麼快更新。直接到 mirror 的網頁目錄看,focal 並沒有出現。

但是不用擔心,因為新版發布時,內建的 packages info 中收錄的絕大多數軟體都非常的新,基本上跟你自己抓的差不了多少。

執行 apt show docker.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
29
30
31
32
33
34
35
Package: docker.io
Version: 19.03.8-0ubuntu1
Built-Using: glibc (= 2.31-0ubuntu4)
Priority: optional
Section: universe/admin
Origin: Ubuntu
Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
Original-Maintainer: Paul Tagliamonte <paultag@debian.org>
Bugs: https://bugs.launchpad.net/ubuntu/+filebug
Installed-Size: 192 MB
Depends: adduser, containerd (>= 1.2.6-0ubuntu1~), iptables, debconf (>= 0.5) | debconf-2.0, libc6 (>= 2.8), libdevmapper1.02.1 (>= 2:1.02.97), libseccomp2 (>= 2.1.0), libsystemd0 (>= 209~)
Recommends: ca-certificates, cgroupfs-mount | cgroup-lite, git, pigz, ubuntu-fan, xz-utils, apparmor
Suggests: aufs-tools, btrfs-progs, debootstrap, docker-doc, rinse, zfs-fuse | zfsutils
Breaks: docker (<< 1.5~)
Replaces: docker (<< 1.5~)
Homepage: https://www.docker.com/community-edition
Download-Size: 38.9 MB
APT-Manual-Installed: yes
APT-Sources: http://free.nchc.org.tw/ubuntu focal/universe amd64 Packages
Description: Linux container runtime
 Docker complements kernel namespacing with a high-level API which operates at
 the process level. It runs unix processes with strong guarantees of isolation
 and repeatability across servers.
 .
 Docker is a great building block for automating distributed systems:
 large-scale web deployments, database clusters, continuous deployment systems,
 private PaaS, service-oriented architectures, etc.
 .
 This package contains the daemon and client. Using docker.io on non-amd64 hosts
 is not supported at this time. Please be careful when using it on anything
 besides amd64.
 .
 Also, note that kernel version 3.8 or above is required for proper operation of
 the daemon process, and that any lower versions may have subtle and/or glaring
 issues.

目前的最新發行版也是 19.03.8


執行 apt show docker-compose 查看 Docker Compose 版本:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
Package: docker-compose
Version: 1.25.0-1
Priority: optional
Section: universe/admin
Origin: Ubuntu
Maintainer: Ubuntu Developers <[email protected]>
Original-Maintainer: Docker Compose Team <[email protected]>
Bugs: https://bugs.launchpad.net/ubuntu/+filebug
Installed-Size: 667 kB
Depends: python3-cached-property (>= 1.2.0), python3-docker (>= 4.0.0), python3-dockerpty (>= 0.4.1), python3-docopt (>= 0.6.1), python3-jsonschema, python3-requests (>= 2.20.0), python3-six (<< 2), python3-six (>= 1.3.0), python3-texttable (>= 0.9.0), python3-websocket (>= 0.32.0), python3-yaml (>= 3.10), python3:any (>= 3.6~), python3-distutils
Recommends: docker.io (>= 1.9.0)
Homepage: https://docs.docker.com/compose/
Download-Size: 92.7 kB
APT-Manual-Installed: yes
APT-Sources: http://free.nchc.org.tw/ubuntu focal/universe amd64 Packages
Description: Punctual, lightweight development environments using Docker
 docker-compose is a service management software built on top of docker. Define
 your services and their relationships in a simple YAML file, and let compose
 handle the rest.

Docker Compose 不是最新版,但其實也就只有 patch 版號有差而已,minor 是一樣的,不構成問題。

所以就放心的直接安裝系統自帶的版本就可以了~

1
sudo apt install -y docker.io docker-compose

檢查狀態,一切正常

 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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
calos@ubuntu-server-focal:~$ sudo docker info
Client:
 Debug Mode: false

Server:
 Containers: 0
  Running: 0
  Paused: 0
  Stopped: 0
 Images: 0
 Server Version: 19.03.8
 Storage Driver: overlay2
  Backing Filesystem: <unknown>
  Supports d_type: true
  Native Overlay Diff: true
 Logging Driver: json-file
 Cgroup Driver: cgroupfs
 Plugins:
  Volume: local
  Network: bridge host ipvlan macvlan null overlay
  Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
 Swarm: inactive
 Runtimes: runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version:
 runc version:
 init version:
 Security Options:
  apparmor
  seccomp
   Profile: default
 Kernel Version: 5.4.0-26-generic
 Operating System: Ubuntu 20.04 LTS
 OSType: linux
 Architecture: x86_64
 CPUs: 2
 Total Memory: 3.817GiB
 Name: ubuntu-server-focal
 ID: C6PM:ZCVS:NXVA:7SBG:P373:2SZJ:7FJB:C7XF:2HC6:QUE2:AJYW:MQGG
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 Registry: https://index.docker.io/v1/
 Labels:
 Experimental: false
 Insecure Registries:
  127.0.0.0/8
 Live Restore Enabled: false

WARNING: No swap limit support

calos@ubuntu-server-focal:~$ sudo docker-compose -v
docker-compose version 1.25.0, build unknown
comments powered by Disqus