ubuntu 安装 docker 详细步骤

发布于:2025-09-09 ⋅ 阅读:(20) ⋅ 点赞:(0)

登录,ubuntu版本 22.04

wqbboy@192.168.1.2's password:
Welcome to Ubuntu 22.04.5 LTS (GNU/Linux 5.15.0-153-generic x86_64)

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

 System information as of Mon Sep  8 01:27:24 PM UTC 2025

  System load:             1.99
  Usage of /:              61.3% of 23.16GB
  Memory usage:            53%
  Swap usage:              0%
  Processes:               193
  Users logged in:         0
  IPv4 address for enp0s3: 192.168.1.2
  IPv6 address for enp0s3: 2409:8a4c:7255:f380:a00:27ff:fe63:1f6d

 * Strictly confined Kubernetes makes edge and IoT secure. Learn how MicroK8s
   just raised the bar for easy, resilient and secure K8s cluster deployment.

   https://ubuntu.com/engage/secure-kubernetes-at-the-edge

Expanded Security Maintenance for Applications is not enabled.

54 updates can be applied immediately.
To see these additional updates run: apt list --upgradable

Enable ESM Apps to receive additional future security updates.
See https://ubuntu.com/esm or run: sudo pro status

New release '24.04.3 LTS' available.
Run 'do-release-upgrade' to upgrade to it.


Last login: Mon Sep  8 13:27:24 2025

查看docker


wqbboy@mail:~$ docker --version
Command 'docker' not found, but can be installed with:
sudo snap install docker         # version 28.1.1+1, or
sudo apt  install docker.io      # version 27.5.1-0ubuntu3~22.04.2
sudo apt  install podman-docker  # version 3.4.4+ds1-1ubuntu1.22.04.3
See 'snap info docker' for additional versions.


安装前提依赖


wqbboy@mail:~$ sudo -i
[sudo] password for wqbboy:
root@mail:~# apt-get update
Hit:1 http://mirrors.aliyun.com/ubuntu jammy InRelease
Get:2 http://mirrors.aliyun.com/ubuntu jammy-updates InRelease [128 kB]
Get:3 http://mirrors.aliyun.com/ubuntu jammy-backports InRelease [127 kB]
Get:4 http://security.ubuntu.com/ubuntu jammy-security InRelease [129 kB]
Fetched 384 kB in 5s (76.9 kB/s)
Reading package lists... Done
root@mail:~# apt-get install ca-certificates curl gnupg lsb-release
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
lsb-release is already the newest version (11.1.0ubuntu4).
lsb-release set to manually installed.
ca-certificates is already the newest version (20240203~22.04.1).
ca-certificates set to manually installed.
curl is already the newest version (7.81.0-1ubuntu1.20).
gnupg is already the newest version (2.2.27-3ubuntu2.4).
gnupg set to manually installed.
0 upgraded, 0 newly installed, 0 to remove and 53 not upgraded.

安装GPG证书(aliyun)


root@mail:~# curl -fsSL http://mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg | s                     udo apt-key add -
Warning: apt-key is deprecated. Manage keyring files in trusted.gpg.d instead (s                     ee apt-key(8)).
OK

写入软件源信息


root@mail:~# add-apt-repository "deb [arch=amd64] http://mirrors.aliyun.com/dock                     er-ce/linux/ubuntu $(lsb_release -cs) stable"
Repository: 'deb [arch=amd64] http://mirrors.aliyun.com/docker-ce/linux/ubuntu j                     ammy stable'
Description:
Archive for codename: jammy components: stable
More info: http://mirrors.aliyun.com/docker-ce/linux/ubuntu
Adding repository.
Press [ENTER] to continue or Ctrl-c to cancel.
Adding deb entry to /etc/apt/sources.list.d/archive_uri-http_mirrors_aliyun_com_                     docker-ce_linux_ubuntu-jammy.list
Adding disabled deb-src entry to /etc/apt/sources.list.d/archive_uri-http_mirror                     s_aliyun_com_docker-ce_linux_ubuntu-jammy.list
Hit:1 http://security.ubuntu.com/ubuntu jammy-security InRelease
Hit:2 http://mirrors.aliyun.com/ubuntu jammy InRelease
Hit:3 http://mirrors.aliyun.com/ubuntu jammy-updates InRelease
Hit:4 http://mirrors.aliyun.com/ubuntu jammy-backports InRelease
Get:5 http://mirrors.aliyun.com/docker-ce/linux/ubuntu jammy InRelease [48.8 kB]
Get:6 http://mirrors.aliyun.com/docker-ce/linux/ubuntu jammy/stable amd64 Packag                     es [55.2 kB]
Fetched 104 kB in 11s (9,650 B/s)
Reading package lists... Done
W: http://mirrors.aliyun.com/docker-ce/linux/ubuntu/dists/jammy/InRelease: Key i                     s stored in legacy trusted.gpg keyring (/etc/apt/trusted.gpg), see the DEPRECATI                     ON section in apt-key(8) for details.

cat 查看证书


root@mail:~# cat /etc/apt/sources.list.d/archive_uri-http_mirrors_aliyun_com_docker-ce_linux_ubuntu-jammy.list
deb [arch=amd64] http://mirrors.aliyun.com/docker-ce/linux/ubuntu jammy stable
# deb-src [arch=amd64] http://mirrors.aliyun.com/docker-ce/linux/ubuntu jammy stable

安装docker安装新版本


root@mail:~# apt-get install docker-ce docker-ce-cli containerd.io
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following additional packages will be installed:
  docker-buildx-plugin docker-ce-rootless-extras docker-compose-plugin libslirp0 pigz slirp4netns
Suggested packages:
  cgroupfs-mount | cgroup-lite docker-model-plugin
The following NEW packages will be installed:
  containerd.io docker-buildx-plugin docker-ce docker-ce-cli docker-ce-rootless-extras
  docker-compose-plugin libslirp0 pigz slirp4netns
0 upgraded, 9 newly installed, 0 to remove and 53 not upgraded.
Need to get 103 MB of archives.
After this operation, 431 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://mirrors.aliyun.com/docker-ce/linux/ubuntu jammy/stable amd64 containerd.io amd64 1.7.27-1 [30.5 MB]
Get:2 http://mirrors.aliyun.com/docker-ce/linux/ubuntu jammy/stable amd64 docker-ce-cli amd64 5:28.4.0-1~ubuntu.22.04~jammy [16.5 MB]
Get:3 http://mirrors.aliyun.com/docker-ce/linux/ubuntu jammy/stable amd64 docker-ce amd64 5:28.4.0-1~ubuntu.22.04~jammy [19.7 MB]
Get:4 http://mirrors.aliyun.com/ubuntu jammy/universe amd64 pigz amd64 2.6-1 [63.6 kB]
Get:5 http://mirrors.aliyun.com/docker-ce/linux/ubuntu jammy/stable amd64 docker-buildx-plugin amd64 0.27.0-1~ubuntu.22.04~jammy [15.9 MB]
Get:6 http://mirrors.aliyun.com/docker-ce/linux/ubuntu jammy/stable amd64 docker-ce-rootless-extras amd64 5:28.4.0-1~ubuntu.22.04~jammy [6,479 kB]
Get:7 http://mirrors.aliyun.com/docker-ce/linux/ubuntu jammy/stable amd64 docker-compose-plugin amd64 2.39.2-1~ubuntu.22.04~jammy [14.2 MB]
Get:8 http://mirrors.aliyun.com/ubuntu jammy/main amd64 libslirp0 amd64 4.6.1-1build1 [61.5 kB]
Get:9 http://mirrors.aliyun.com/ubuntu jammy/universe amd64 slirp4netns amd64 1.0.1-2 [28.2 kB]
Fetched 103 MB in 10s (10.3 MB/s)
Selecting previously unselected package containerd.io.
(Reading database ... 90305 files and directories currently installed.)
Preparing to unpack .../0-containerd.io_1.7.27-1_amd64.deb ...
Unpacking containerd.io (1.7.27-1) ...
Selecting previously unselected package docker-ce-cli.
Preparing to unpack .../1-docker-ce-cli_5%3a28.4.0-1~ubuntu.22.04~jammy_amd64.deb ...
Unpacking docker-ce-cli (5:28.4.0-1~ubuntu.22.04~jammy) ...
Selecting previously unselected package docker-ce.
Preparing to unpack .../2-docker-ce_5%3a28.4.0-1~ubuntu.22.04~jammy_amd64.deb ...
Unpacking docker-ce (5:28.4.0-1~ubuntu.22.04~jammy) ...
Selecting previously unselected package pigz.
Preparing to unpack .../3-pigz_2.6-1_amd64.deb ...
Unpacking pigz (2.6-1) ...
Selecting previously unselected package docker-buildx-plugin.
Preparing to unpack .../4-docker-buildx-plugin_0.27.0-1~ubuntu.22.04~jammy_amd64.deb ...
Unpacking docker-buildx-plugin (0.27.0-1~ubuntu.22.04~jammy) ...
Selecting previously unselected package docker-ce-rootless-extras.
Preparing to unpack .../5-docker-ce-rootless-extras_5%3a28.4.0-1~ubuntu.22.04~jammy_amd64.deb ...
Unpacking docker-ce-rootless-extras (5:28.4.0-1~ubuntu.22.04~jammy) ...
Selecting previously unselected package docker-compose-plugin.
Preparing to unpack .../6-docker-compose-plugin_2.39.2-1~ubuntu.22.04~jammy_amd64.deb ...
Unpacking docker-compose-plugin (2.39.2-1~ubuntu.22.04~jammy) ...
Selecting previously unselected package libslirp0:amd64.
Preparing to unpack .../7-libslirp0_4.6.1-1build1_amd64.deb ...
Unpacking libslirp0:amd64 (4.6.1-1build1) ...
Selecting previously unselected package slirp4netns.
Preparing to unpack .../8-slirp4netns_1.0.1-2_amd64.deb ...
Unpacking slirp4netns (1.0.1-2) ...
Setting up docker-buildx-plugin (0.27.0-1~ubuntu.22.04~jammy) ...
Setting up containerd.io (1.7.27-1) ...
Created symlink /etc/systemd/system/multi-user.target.wants/containerd.service → /lib/systemd/system/containerd.service.
Setting up docker-compose-plugin (2.39.2-1~ubuntu.22.04~jammy) ...
Setting up docker-ce-cli (5:28.4.0-1~ubuntu.22.04~jammy) ...
Setting up libslirp0:amd64 (4.6.1-1build1) ...
Setting up pigz (2.6-1) ...
Setting up docker-ce-rootless-extras (5:28.4.0-1~ubuntu.22.04~jammy) ...
Setting up slirp4netns (1.0.1-2) ...
Setting up docker-ce (5:28.4.0-1~ubuntu.22.04~jammy) ...
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.10.2-1) ...
Processing triggers for libc-bin (2.35-0ubuntu3.10) ...
Scanning processes...
Scanning linux images...

Running kernel seems to be up-to-date.

No services need to be restarted.

No containers need to be restarted.

No user sessions are running outdated binaries.

No VM guests are running outdated hypervisor (qemu) binaries on this host.
root@mail:~#

增加用户组,查看docker状态

root@mail:~# groupadd docker
groupadd: group 'docker' already exists
root@mail:~# systemctl status docker
● docker.service - Docker Application Container Engine
     Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled)
     Active: active (running) since Mon 2025-09-08 13:32:44 UTC; 7min ago
TriggeredBy: ● docker.socket
       Docs: https://docs.docker.com
   Main PID: 4863 (dockerd)
      Tasks: 10
     Memory: 22.9M
        CPU: 679ms
     CGroup: /system.slice/docker.service
             └─4863 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock

Sep 08 13:32:43 mail dockerd[4863]: time="2025-09-08T13:32:43.223417116Z" level=info msg="detected 1>
Sep 08 13:32:43 mail dockerd[4863]: time="2025-09-08T13:32:43.310117771Z" level=info msg="Creating a>
Sep 08 13:32:43 mail dockerd[4863]: time="2025-09-08T13:32:43.933020832Z" level=info msg="Loading co>
Sep 08 13:32:44 mail dockerd[4863]: time="2025-09-08T13:32:44.435076303Z" level=info msg="Loading co>
Sep 08 13:32:44 mail dockerd[4863]: time="2025-09-08T13:32:44.491334552Z" level=info msg="Docker dae>
Sep 08 13:32:44 mail dockerd[4863]: time="2025-09-08T13:32:44.491741783Z" level=info msg="Initializi>
Sep 08 13:32:44 mail dockerd[4863]: time="2025-09-08T13:32:44.552230002Z" level=info msg="Completed >
Sep 08 13:32:44 mail dockerd[4863]: time="2025-09-08T13:32:44.562534686Z" level=info msg="Daemon has>
Sep 08 13:32:44 mail dockerd[4863]: time="2025-09-08T13:32:44.563030422Z" level=info msg="API listen>
Sep 08 13:32:44 mail systemd[1]: Started Docker Application Container Engine.
lines 1-22/22 (END)

查看docker版本

root@mail:~# docker --version
Docker version 28.4.0, build d8eb465
root@mail:~# docker-compose --version
Command 'docker-compose' not found, but can be installed with:
snap install docker          # version 28.1.1+1, or
apt  install docker-compose  # version 1.29.2-1
See 'snap info docker' for additional versions.
root@mail:~# docker --version
Docker version 28.4.0, build d8eb465

docker换源


root@mail:~# vi /etc/docker/daemon.json


安装docker-compose


root@mail:~# apt-get install docker-compose
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following additional packages will be installed:
  python3-docker python3-dockerpty python3-docopt python3-dotenv python3-texttable
  python3-websocket
Recommended packages:
  docker.io
The following NEW packages will be installed:
  docker-compose python3-docker python3-dockerpty python3-docopt python3-dotenv python3-texttable
  python3-websocket
0 upgraded, 7 newly installed, 0 to remove and 53 not upgraded.
Need to get 290 kB of archives.
After this operation, 1,545 kB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://mirrors.aliyun.com/ubuntu jammy/universe amd64 python3-websocket all 1.2.3-1 [34.7 kB]
Get:2 http://mirrors.aliyun.com/ubuntu jammy/universe amd64 python3-docker all 5.0.3-1 [89.3 kB]
Get:3 http://mirrors.aliyun.com/ubuntu jammy/universe amd64 python3-dockerpty all 0.4.1-2 [11.1 kB]
Get:4 http://mirrors.aliyun.com/ubuntu jammy/universe amd64 python3-docopt all 0.6.2-4 [26.9 kB]
Get:5 http://mirrors.aliyun.com/ubuntu jammy/universe amd64 python3-dotenv all 0.19.2-1 [20.5 kB]
Get:6 http://mirrors.aliyun.com/ubuntu jammy/universe amd64 python3-texttable all 1.6.4-1 [11.4 kB]
Get:7 http://mirrors.aliyun.com/ubuntu jammy/universe amd64 docker-compose all 1.29.2-1 [95.8 kB]
Fetched 290 kB in 0s (961 kB/s)
Selecting previously unselected package python3-websocket.
(Reading database ... 90564 files and directories currently installed.)
Preparing to unpack .../0-python3-websocket_1.2.3-1_all.deb ...
Unpacking python3-websocket (1.2.3-1) ...
Selecting previously unselected package python3-docker.
Preparing to unpack .../1-python3-docker_5.0.3-1_all.deb ...
Unpacking python3-docker (5.0.3-1) ...
Selecting previously unselected package python3-dockerpty.
Preparing to unpack .../2-python3-dockerpty_0.4.1-2_all.deb ...
Unpacking python3-dockerpty (0.4.1-2) ...
Selecting previously unselected package python3-docopt.
Preparing to unpack .../3-python3-docopt_0.6.2-4_all.deb ...
Unpacking python3-docopt (0.6.2-4) ...
Selecting previously unselected package python3-dotenv.
Preparing to unpack .../4-python3-dotenv_0.19.2-1_all.deb ...
Unpacking python3-dotenv (0.19.2-1) ...
Selecting previously unselected package python3-texttable.
Preparing to unpack .../5-python3-texttable_1.6.4-1_all.deb ...
Unpacking python3-texttable (1.6.4-1) ...
Selecting previously unselected package docker-compose.
Preparing to unpack .../6-docker-compose_1.29.2-1_all.deb ...
Unpacking docker-compose (1.29.2-1) ...
Setting up python3-dotenv (0.19.2-1) ...
Setting up python3-texttable (1.6.4-1) ...
Setting up python3-docopt (0.6.2-4) ...
Setting up python3-websocket (1.2.3-1) ...
Setting up python3-dockerpty (0.4.1-2) ...
Setting up python3-docker (5.0.3-1) ...
Setting up docker-compose (1.29.2-1) ...
Processing triggers for man-db (2.10.2-1) ...
Scanning processes...
Scanning linux images...

Running kernel seems to be up-to-date.

No services need to be restarted.

No containers need to be restarted.

No user sessions are running outdated binaries.

No VM guests are running outdated hypervisor (qemu) binaries on this host.

安装必要的一些系统工具


root@mail:~# apt-get -y install apt-transport-https ca-certificates curl software-properties-common
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
ca-certificates is already the newest version (20240203~22.04.1).
curl is already the newest version (7.81.0-1ubuntu1.20).
software-properties-common is already the newest version (0.99.22.9).
software-properties-common set to manually installed.
The following NEW packages will be installed:
  apt-transport-https
0 upgraded, 1 newly installed, 0 to remove and 53 not upgraded.
Need to get 1,510 B of archives.
After this operation, 170 kB of additional disk space will be used.
Get:1 http://mirrors.aliyun.com/ubuntu jammy-updates/universe amd64 apt-transport-https all 2.4.14 [1,510 B]
Fetched 1,510 B in 0s (16.4 kB/s)
Selecting previously unselected package apt-transport-https.
(Reading database ... 90824 files and directories currently installed.)
Preparing to unpack .../apt-transport-https_2.4.14_all.deb ...
Unpacking apt-transport-https (2.4.14) ...
Setting up apt-transport-https (2.4.14) ...
Scanning processes...
Scanning linux images...

Running kernel seems to be up-to-date.

No services need to be restarted.

No containers need to be restarted.

No user sessions are running outdated binaries.

No VM guests are running outdated hypervisor (qemu) binaries on this host.

重启docker,报错,只能删除/etc/docker/daemon.json


root@mail:~# service docker restart
Job for docker.service failed because the control process exited with error code.
See "systemctl status docker.service" and "journalctl -xeu docker.service" for details.
root@mail:~# docker --version
Docker version 28.4.0, build d8eb465
root@mail:~# docker-compose --version
docker-compose version 1.29.2, build unknown
root@mail:~# vi /etc/docker/daemon.json
root@mail:~# service docker restart
Job for docker.service failed because the control process exited with error code.
See "systemctl status docker.service" and "journalctl -xeu docker.service" for details.
root@mail:~# vi /etc/docker/daemon.json
root@mail:~# service docker restart
Job for docker.service failed because the control process exited with error code.
See "systemctl status docker.service" and "journalctl -xeu docker.service" for details.
root@mail:~# vi /etc/docker/daemon.json
root@mail:~# service docker restart
Job for docker.service failed because the control process exited with error code.
See "systemctl status docker.service" and "journalctl -xeu docker.service" for details.
root@mail:~# systemctl status docker.service
× docker.service - Docker Application Container Engine
     Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled)
     Active: failed (Result: exit-code) since Mon 2025-09-08 13:47:59 UTC; 6s ago
TriggeredBy: × docker.socket
       Docs: https://docs.docker.com
    Process: 6895 ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock (>
   Main PID: 6895 (code=exited, status=1/FAILURE)
        CPU: 64ms

Sep 08 13:47:59 mail systemd[1]: docker.service: Scheduled restart job, restart counter is at 3.
Sep 08 13:47:59 mail systemd[1]: Stopped Docker Application Container Engine.
Sep 08 13:47:59 mail systemd[1]: docker.service: Start request repeated too quickly.
Sep 08 13:47:59 mail systemd[1]: docker.service: Failed with result 'exit-code'.
Sep 08 13:47:59 mail systemd[1]: Failed to start Docker Application Container Engine.

root@mail:~# vi /etc/docker/daemon.json
root@mail:~# mv /etc/docker/daemon.json /etc/docker/daemon.jsonbak
root@mail:~# systemctl status docker.service
× docker.service - Docker Application Container Engine
     Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled)
     Active: failed (Result: exit-code) since Mon 2025-09-08 13:47:59 UTC; 1min 9s ago
TriggeredBy: × docker.socket
       Docs: https://docs.docker.com
    Process: 6895 ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock (>
   Main PID: 6895 (code=exited, status=1/FAILURE)
        CPU: 64ms

Sep 08 13:47:59 mail systemd[1]: docker.service: Scheduled restart job, restart counter is at 3.
Sep 08 13:47:59 mail systemd[1]: Stopped Docker Application Container Engine.
Sep 08 13:47:59 mail systemd[1]: docker.service: Start request repeated too quickly.
Sep 08 13:47:59 mail systemd[1]: docker.service: Failed with result 'exit-code'.
Sep 08 13:47:59 mail systemd[1]: Failed to start Docker Application Container Engine.
...skipping...
× docker.service - Docker Application Container Engine
     Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled)
     Active: failed (Result: exit-code) since Mon 2025-09-08 13:47:59 UTC; 1min 9s ago
TriggeredBy: × docker.socket
       Docs: https://docs.docker.com
    Process: 6895 ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock (>
   Main PID: 6895 (code=exited, status=1/FAILURE)
        CPU: 64ms

Sep 08 13:47:59 mail systemd[1]: docker.service: Scheduled restart job, restart counter is at 3.
Sep 08 13:47:59 mail systemd[1]: Stopped Docker Application Container Engine.
Sep 08 13:47:59 mail systemd[1]: docker.service: Start request repeated too quickly.
Sep 08 13:47:59 mail systemd[1]: docker.service: Failed with result 'exit-code'.
Sep 08 13:47:59 mail systemd[1]: Failed to start Docker Application Container Engine.
~


重启


root@mail:~# service docker restart
root@mail:~# docker-compose --version
docker-compose version 1.29.2, build unknown
root@mail:~#

配置daemon.json

root@mail:~# vi /etc/docker/daemon.json

root@mail:~# cat /etc/docker/daemon.json

{
  "registry-mirrors": ["http://hub-mirror.c.163.com"]
}

root@mail:~# service docker restart

解决Error response from daemon: Get https://registry-1.docker.io/v2/library/hello-world/manifests/问题

root@mail:~/snap/lxd# docker image pull library/hello-world
Using default tag: latest
Error response from daemon: Get "https://registry-1.docker.io/v2/": net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)



第一步:**通过 dig @114.114.114.114 registry-1.docker.io找到可用IP


root@mail:~/snap/lxd# dig @114.114.114.114 registry-1.docker.io

; <<>> DiG 9.18.30-0ubuntu0.22.04.2-Ubuntu <<>> @114.114.114.114 registry-1.docker.io
; (1 server found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 65511
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 512
;; QUESTION SECTION:
;registry-1.docker.io.          IN      A

;; ANSWER SECTION:
registry-1.docker.io.   131     IN      A       31.13.76.99

;; Query time: 28 msec
;; SERVER: 114.114.114.114#53(114.114.114.114) (UDP)
;; WHEN: Mon Sep 08 14:14:18 UTC 2025
;; MSG SIZE  rcvd: 65

root@mail:~/snap/lxd#

尝试修改/etc/hosts强制docker.io相关的域名解析到其它可用IP

root@mail:~/snap/lxd# vi /etc/hosts
root@mail:~/snap/lxd# cat /etc/hosts
127.0.0.1 localhost
127.0.1.1 mail.xgpolice.com mail

# The following lines are desirable for IPv6 capable hosts
::1     ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters

31.13.76.99 registry-1.docker.io

保存之后重试:

root@mail:~/snap/lxd# docker image pull library/hello-world
Using default tag: latest


网站公告

今日签到

点亮在社区的每一天
去签到