解决国产系统 Docker 拉取大镜像卡顿之谜

您所在的位置:网站首页 docker卡在下载镜像 解决国产系统 Docker 拉取大镜像卡顿之谜

解决国产系统 Docker 拉取大镜像卡顿之谜

2024-07-14 18:06| 来源: 网络整理| 查看: 265

今天解决了客户 arm64 机器上 docker pull 大镜像卡住的问题。

由来

同事让我帮忙解决客户现场 Docker 镜像无法拉取的问题,故障如下会一直卡住:

$ docker pull xxx:5000/xxxx xxx: Pulling from xxx/xxxxxx 7c0b344a74c2: Extracting [>                                                  ]  294.9kB/26.66MB 7c0b344a74c2: Download complete e53ed7fd3110: Download complete d2cae797bc79: Download complete ec3ddc176f08: Download complete 2969517e196e: Download complete 097fa64722e8: Download complete 1dde4ca01a5a: Download complete

离线文件 load -i 后,打上 tag 推送到镜像仓库,然后本地删除这个镜像,然后拉取还是像上面这样卡住,部分小镜像拉取没问题,所以不可能是 docker data-root 的挂载 option 影响。环境信息如下:

$ docker info ...  Server Version: 19.03.15  Storage Driver: overlay2   Backing Filesystem: extfs   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: ea765aba0d05254012b0b9e595e995c09186427f  runc version: v1.0.0-0-g84113eef  init version: fec3683  Security Options:   seccomp    Profile: default  Kernel Version: 4.19.90-2211.5.0.0178.22.uel20.aarch64  Operating System: UnionTech OS Server 20  OSType: linux  Architecture: aarch64  CPUs: 24  Total Memory: 94.56GiB  Name: host-xxxx  ID: RTQS:5TXE:5T3S:YW7X:OHPK:FZ7D:7EHD:DH5Z:JNBV:FVXS:24FA:EIVS  Docker Root Dir: /data/kube/docker  Debug Mode: true   File Descriptors: 29   Goroutines: 46   System Time: 2023-04-12T16:10:25.33362426+08:00 $ uname -a Linux host-x 4.19.90-2211.5.0.0178.22.uel20.aarch64 #1 SMP Thu Nov 24 10:33:07 CST 2022 aarch64 aarch64 aarch64 GNU/Linux $ cat /etc/os-release PRETTY_NAME="UnionTech OS Server 20" NAME="UnionTech OS Server 20" VERSION_ID="20" VERSION="20" ID=uos HOME_URL="https://www.chinauos.com/" BUG_REPORT_URL="https://bbs.chinauos.com/" VERSION_CODENAME=fuyu PLATFORM_ID="platform:uel20" 排查

卡住的过程中,另外开一个 ssh top 发现进程 unpigz 占用较高,利用其 pid 查看了一些信息:

$ pstree -sp 1170083 systemd(1)───dockerd(1169795)───unpigz(1170083)─┬─{unpigz}(1170084)                                                 ├─{unpigz}(1170086)                                                 └─{unpigz}(1170087)

发现这个进程是 Docker 调用的,strace 只能看到卡住,kill 了 unpigz 后,卡住的 pull 开始报错了:

failed to register layer: Error processing tar file(exit status 1): unexpected EOF

Docker 的镜像每层 layer 实际是 tar,pull 时会下载 tar 包然后解压,这个看着是解压相关的逻辑出现了问题。在 Docker 源码里搜索 Error processing tar file 后找到:

// https://github.com/moby/moby/blob/v19.03.15/pkg/chrootarchive/archive_unix.go#L90-L116  cmd := reexec.Command("docker-untar", dest, root)   ...  if err := cmd.Wait(); err != nil {   // when `xz -d -c -q | docker-untar ...` failed on docker-untar side,   // we need to exhaust `xz`'s output, otherwise the `xz` side will be   // pending on write pipe forever   io.Copy(ioutil.Discard, decompressedArchive)   return fmt.Errorf("Error processing tar file(%v): %s", err, output)  }  return nil

看注释里的xz -d -c -q | docker-untar ...,与 unpigz 的 cmdline 和一个卡住的 docker-untar 进程相符:

$ xargs -0 


【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3