[BUG] `up` pulls an image once per service when several services share it

未关闭
#14,463 1 条评论 0 个 reaction 已指派 1 人 在 GitHub 查看

维护者通常 1 天内回复

@ndeloof 已经在做这个了。

开始于 2026年11月6日。

  • #14464 来自 @ndeloof —— 未关闭

评估

这个 Issue 还没有评估数据。

描述

kind/bug status/approved
Description

When several services use the same missing image, docker compose up sends one pull request
per service. docker compose pull pulls the image once (fixed for #8768).

With the containerd image store, every one of these pulls also unpacks the layers. On a stack of
21 services sharing one 5.7 GB image, up ran 21 parallel unpacks of the same layers on an
NVIDIA Jetson Thor. containerd logged about 17,600 (*service).Write failed ... ref moby/1/layer-sha256:... locked errors while the pulls waited on each other, and the progress
display stayed at 5.675 GB / 5.683 GB for several minutes while the load average was about 35.

Steps To Reproduce

compose.yaml:

services:
  a:
    image: alpine:3.20.3
    command: ["sleep", "infinity"]
  b:
    image: alpine:3.20.3
    command: ["sleep", "infinity"]
  c:
    image: alpine:3.20.3
    command: ["sleep", "infinity"]

repro.sh (removes alpine:3.20.3 and counts the engine's pull events):

#!/usr/bin/env bash
set -euo pipefail
cd "$(dirname "$0")"

count_pulls() {
  docker compose down --timeout 0 >/dev/null 2>&1
  docker image rm --force alpine:3.20.3 >/dev/null 2>&1 || true
  docker events --filter type=image --filter event=pull --format '{{.Action}} {{.Actor.ID}}' > events.log &
  local events_pid=$!
  sleep 1
  docker compose "$@" >/dev/null 2>&1
  sleep 2
  kill "$events_pid"
  echo "docker compose $*: $(wc -l < events.log) pull(s)"
}

count_pulls pull
count_pulls up --detach
docker compose down --timeout 0 >/dev/null 2>&1
rm -f events.log

Output:

docker compose pull: 1 pull(s)
docker compose up --detach: 3 pull(s)

Expected: up --detach pulls the image once, like pull.

Compose Version
Docker Compose version v5.6.1
Docker Environment
Client and server 29.9.2, Fedora Linux 45 (Workstation Edition), x86_64,
storage driver overlayfs with io.containerd.snapshotter.v1
Anything else?

No response

主要语言
Go
星标
38.9k
派生
6k
平均合并
2 天 22 小时
30 天内合并 PR
81

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

docker/compose 的其他 Issue

查看 docker/compose 的全部 Issue

相似的 Issue

更多 Go Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。