Debian 12(bookworm)安装Docker

  1. 查看系统版本
hotpod@iZuf639kwmsyssxs0c0n9mZ:~$ (. /etc/os-release && echo "$VERSION_CODENAME")
bookworm
  1. 安装必要软件包
hotpod@iZuf639kwmsyssxs0c0n9mZ:~$ api ca-certificates curl gnupg
[sudo] password for hotpod: 
ca-certificates is already installed at the requested version (20230311)
curl is already installed at the requested version (7.88.1-10+deb12u4)
gnupg is already installed at the requested version (2.2.40-1.1)
ca-certificates is already installed at the requested version (20230311)
curl is already installed at the requested version (7.88.1-10+deb12u4)
gnupg is already installed at the requested version (2.2.40-1.1)
No packages will be installed, upgraded, or removed.
0 packages upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Need to get 0 B of archives. After unpacking 0 B will be used.
  1. 配置Docker gpg证书
hotpod@iZuf639kwmsyssxs0c0n9mZ:~$ sudo install -m 0755 -d /etc/apt/keyrings
hotpod@iZuf639kwmsyssxs0c0n9mZ:~$ curl -fsSL https://download.docker.com/linux/debian/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
hotpod@iZuf639kwmsyssxs0c0n9mZ:~$ sudo chmod a+r /etc/apt/keyrings/docker.gpg
hotpod@iZuf639kwmsyssxs0c0n9mZ:~$ echo \
  "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/debian \
  $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \

sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
  1. 更新软件源
hotpod@iZuf639kwmsyssxs0c0n9mZ:~$ sudo aptitude update
Hit http://mirrors.cloud.aliyuncs.com/debian bookworm InRelease
Get: 1 http://mirrors.cloud.aliyuncs.com/debian-security bookworm-security InRelease [48.0 kB]
Get: 2 http://mirrors.cloud.aliyuncs.com/debian bookworm-updates InRelease [52.1 kB]
Get: 3 http://mirrors.cloud.aliyuncs.com/debian bookworm-backports InRelease [56.5 kB]
Get: 4 http://mirrors.cloud.aliyuncs.com/debian-security bookworm-security/main Sources [62.4 kB]
Get: 5 http://mirrors.cloud.aliyuncs.com/debian-security bookworm-security/main amd64 Packages [106 kB]
Get: 6 http://mirrors.cloud.aliyuncs.com/debian-security bookworm-security/main Translation-en [64.1 kB]
Get: 7 http://mirrors.cloud.aliyuncs.com/debian bookworm-backports/main Sources.diff/Index [63.3 kB]
Get: 8 http://mirrors.cloud.aliyuncs.com/debian bookworm-backports/main amd64 Packages.diff/Index [63.3 kB]
Get: 9 http://mirrors.cloud.aliyuncs.com/debian bookworm-backports/main Translation-en.diff/Index [38.7 kB]
Get: 10 http://mirrors.cloud.aliyuncs.com/debian bookworm-backports/main Sources T-2023-12-07-0205.52-F-2023-11-26-0203.42.pdiff [42.5 kB]
Get: 11 https://download.docker.com/linux/debian bookworm InRelease [43.3 kB]
Get: 12 http://mirrors.cloud.aliyuncs.com/debian bookworm-backports/main Sources T-2023-12-07-0205.52-F-2023-11-26-0203.42.pdiff [42.5 kB]
Get: 13 http://mirrors.cloud.aliyuncs.com/debian bookworm-backports/main amd64 Packages T-2023-12-07-0205.52-F-2023-11-26-2009.18.pdiff [45.4 kB]
Get: 14 http://mirrors.cloud.aliyuncs.com/debian bookworm-backports/main amd64 Packages T-2023-12-07-0205.52-F-2023-11-26-2009.18.pdiff [45.4 kB]
Get: 15 http://mirrors.cloud.aliyuncs.com/debian bookworm-backports/main Translation-en T-2023-12-05-0206.02-F-2023-11-27-1404.10.pdiff [8,464 B]
Get: 16 http://mirrors.cloud.aliyuncs.com/debian bookworm-backports/main Translation-en T-2023-12-05-0206.02-F-2023-11-27-1404.10.pdiff [8,464 B]
Get: 17 https://download.docker.com/linux/debian bookworm/stable amd64 Packages [13.3 kB]
Fetched 708 kB in 1s (708 kB/s)       

Current status: 2 (+2) upgradable, 27 (+27) new.
  1. 安装Docker
hotpod@iZuf639kwmsyssxs0c0n9mZ:~$ api docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
The following NEW packages will be installed:
  containerd.io docker-buildx-plugin docker-ce docker-ce-cli docker-ce-rootless-extras{a} 
  docker-compose-plugin iptables{a} libip6tc2{a} libltdl7{a} libnetfilter-conntrack3{a} 
  libnfnetlink0{a} libslirp0{a} pigz{a} slirp4netns{a} 
0 packages upgraded, 14 newly installed, 0 to remove and 2 not upgraded.
Need to get 115 MB of archives. After unpacking 412 MB will be used.
Do you want to continue? [Y/n/?] y
Get: 1 http://mirrors.cloud.aliyuncs.com/debian bookworm/main amd64 pigz amd64 2.6-1 [64.0 kB]
Get: 2 http://mirrors.cloud.aliyuncs.com/debian bookworm/main amd64 libip6tc2 amd64 1.8.9-2 [19.4 kB]
Get: 3 http://mirrors.cloud.aliyuncs.com/debian bookworm/main amd64 libnfnetlink0 amd64 1.0.2-2 [15.1 kB]
Get: 4 http://mirrors.cloud.aliyuncs.com/debian bookworm/main amd64 libnetfilter-conntrack3 amd64 1.0.9-3 [40.7 kB]
Get: 5 http://mirrors.cloud.aliyuncs.com/debian bookworm/main amd64 iptables amd64 1.8.9-2 [360 kB]   
Get: 6 http://mirrors.cloud.aliyuncs.com/debian bookworm/main amd64 libltdl7 amd64 2.4.7-5 [393 kB]
Get: 7 http://mirrors.cloud.aliyuncs.com/debian bookworm/main amd64 libslirp0 amd64 4.7.0-1 [63.0 kB]
Get: 8 http://mirrors.cloud.aliyuncs.com/debian bookworm/main amd64 slirp4netns amd64 1.2.0-1 [37.5 kB]
Get: 9 https://download.docker.com/linux/debian bookworm/stable amd64 containerd.io amd64 1.6.25-1 [28.7 MB]
Get: 10 https://download.docker.com/linux/debian bookworm/stable amd64 docker-buildx-plugin amd64 0.11.2-1~debian.12~bookworm [28.2 MB]
Get: 11 https://download.docker.com/linux/debian bookworm/stable amd64 docker-ce-cli amd64 5:24.0.7-1~debian.12~bookworm [13.3 MB]
Get: 12 https://download.docker.com/linux/debian bookworm/stable amd64 docker-ce amd64 5:24.0.7-1~debian.12~bookworm [22.5 MB]
Get: 13 https://download.docker.com/linux/debian bookworm/stable amd64 docker-ce-rootless-extras amd64 5:24.0.7-1~debian.12~bookworm [9,030 kB]
Get: 14 https://download.docker.com/linux/debian bookworm/stable amd64 docker-compose-plugin amd64 2.21.0-1~debian.12~bookworm [11.9 MB]
Fetched 115 MB in 10s (11.5 MB/s)                                                                        
Selecting previously unselected package pigz.
(Reading database ... 93881 files and directories currently installed.)
Preparing to unpack .../00-pigz_2.6-1_amd64.deb ...
Unpacking pigz (2.6-1) ...
Selecting previously unselected package containerd.io.
Preparing to unpack .../01-containerd.io_1.6.25-1_amd64.deb ...
Unpacking containerd.io (1.6.25-1) ...
Selecting previously unselected package docker-buildx-plugin.
Preparing to unpack .../02-docker-buildx-plugin_0.11.2-1~debian.12~bookworm_amd64.deb ...
Unpacking docker-buildx-plugin (0.11.2-1~debian.12~bookworm) ...
Selecting previously unselected package docker-ce-cli.
Preparing to unpack .../03-docker-ce-cli_5%3a24.0.7-1~debian.12~bookworm_amd64.deb ...
Unpacking docker-ce-cli (5:24.0.7-1~debian.12~bookworm) ...
Selecting previously unselected package libip6tc2:amd64.
Preparing to unpack .../04-libip6tc2_1.8.9-2_amd64.deb ...
Unpacking libip6tc2:amd64 (1.8.9-2) ...
Selecting previously unselected package libnfnetlink0:amd64.
Preparing to unpack .../05-libnfnetlink0_1.0.2-2_amd64.deb ...
Unpacking libnfnetlink0:amd64 (1.0.2-2) ...
Selecting previously unselected package libnetfilter-conntrack3:amd64.
Preparing to unpack .../06-libnetfilter-conntrack3_1.0.9-3_amd64.deb ...
Unpacking libnetfilter-conntrack3:amd64 (1.0.9-3) ...
Selecting previously unselected package iptables.
Preparing to unpack .../07-iptables_1.8.9-2_amd64.deb ...
Unpacking iptables (1.8.9-2) ...
Selecting previously unselected package docker-ce.
Preparing to unpack .../08-docker-ce_5%3a24.0.7-1~debian.12~bookworm_amd64.deb ...
Unpacking docker-ce (5:24.0.7-1~debian.12~bookworm) ...
Selecting previously unselected package docker-ce-rootless-extras.
Preparing to unpack .../09-docker-ce-rootless-extras_5%3a24.0.7-1~debian.12~bookworm_amd64.deb ...
Unpacking docker-ce-rootless-extras (5:24.0.7-1~debian.12~bookworm) ...
Selecting previously unselected package docker-compose-plugin.
Preparing to unpack .../10-docker-compose-plugin_2.21.0-1~debian.12~bookworm_amd64.deb ...
Unpacking docker-compose-plugin (2.21.0-1~debian.12~bookworm) ...
Selecting previously unselected package libltdl7:amd64.
Preparing to unpack .../11-libltdl7_2.4.7-5_amd64.deb ...
Unpacking libltdl7:amd64 (2.4.7-5) ...
Selecting previously unselected package libslirp0:amd64.
Preparing to unpack .../12-libslirp0_4.7.0-1_amd64.deb ...
Unpacking libslirp0:amd64 (4.7.0-1) ...
Selecting previously unselected package slirp4netns.
Preparing to unpack .../13-slirp4netns_1.2.0-1_amd64.deb ...
Unpacking slirp4netns (1.2.0-1) ...
Setting up libip6tc2:amd64 (1.8.9-2) ...
Setting up docker-buildx-plugin (0.11.2-1~debian.12~bookworm) ...
Setting up containerd.io (1.6.25-1) ...
Created symlink /etc/systemd/system/multi-user.target.wants/containerd.service → /lib/systemd/system/containerd.service.
Setting up docker-compose-plugin (2.21.0-1~debian.12~bookworm) ...
Setting up libltdl7:amd64 (2.4.7-5) ...
Setting up docker-ce-cli (5:24.0.7-1~debian.12~bookworm) ...
Setting up libslirp0:amd64 (4.7.0-1) ...
Setting up pigz (2.6-1) ...
Setting up libnfnetlink0:amd64 (1.0.2-2) ...
Setting up docker-ce-rootless-extras (5:24.0.7-1~debian.12~bookworm) ...
Setting up slirp4netns (1.2.0-1) ...
Setting up libnetfilter-conntrack3:amd64 (1.0.9-3) ...
Setting up iptables (1.8.9-2) ...
update-alternatives: using /usr/sbin/iptables-legacy to provide /usr/sbin/iptables (iptables) in auto mode
update-alternatives: using /usr/sbin/ip6tables-legacy to provide /usr/sbin/ip6tables (ip6tables) in auto mode
update-alternatives: using /usr/sbin/iptables-nft to provide /usr/sbin/iptables (iptables) in auto mode
update-alternatives: using /usr/sbin/ip6tables-nft to provide /usr/sbin/ip6tables (ip6tables) in auto mode
update-alternatives: using /usr/sbin/arptables-nft to provide /usr/sbin/arptables (arptables) in auto mode
update-alternatives: using /usr/sbin/ebtables-nft to provide /usr/sbin/ebtables (ebtables) in auto mode
Setting up docker-ce (5:24.0.7-1~debian.12~bookworm) ...
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.
Processing triggers for man-db (2.11.2-2) ...
Processing triggers for libc-bin (2.36-9+deb12u3) ...
  1. 测试Docker
hotpod@iZuf639kwmsyssxs0c0n9mZ:~$ sudo docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
719385e32844: Pull complete 
Digest: sha256:c79d06dfdfd3d3eb04cafd0dc2bacab0992ebc243e083cabe208bac4dd7759e0
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/
  1. 查看Docker版本
hotpod@iZuf639kwmsyssxs0c0n9mZ:~$ sudo docker version
Client: Docker Engine - Community
 Version:           24.0.7
 API version:       1.43
 Go version:        go1.20.10
 Git commit:        afdd53b
 Built:             Thu Oct 26 09:08:02 2023
 OS/Arch:           linux/amd64
 Context:           default

Server: Docker Engine - Community
 Engine:
  Version:          24.0.7
  API version:      1.43 (minimum version 1.12)
  Go version:       go1.20.10
  Git commit:       311b9ff
  Built:            Thu Oct 26 09:08:02 2023
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.6.25
  GitCommit:        d8f198a4ed8892c764191ef7b3b06d8a2eeb5c7f
 runc:
  Version:          1.1.10
  GitCommit:        v1.1.10-0-g18a0cb0
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0

results matching ""

    No results matching ""

    results matching ""

      No results matching ""