Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

[BUG] `docker compose run` drops the anonymous volumes of a dependency it recreates

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

维护者通常 1 天内回复

@htoyoda18 已经在做这个了。

开始于 2026年10月17日。

  • #14358 来自 @htoyoda18 —— 未关闭

评估

难度
3/5
预计耗时
1-2 天
新手友好度
25/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
停滞
技术栈
docker, docker-compose, go

调研方向

Trace the implementation of docker compose run when it recreates a dependency, focusing on how anonymous volumes are transferred between container generations; compare that path with docker compose up. Use the provided Compose YAML and commands to reproduce the lost data, then add or update tests confirming that run preserves dependency volumes. This work is already being addressed by linked pull request #14358.

由索引模型根据 Issue 内容生成。

描述

kind/bug status/0-triage
Description

When docker compose run recreates a dependency whose configuration changed, the new container gets fresh, empty anonymous volumes instead of the old ones. A database dependency (any image declaring VOLUME, e.g. postgres or mysql) then looks wiped. docker compose up carries the same anonymous volumes over to the recreated container, so the data stays.

The data is not deleted: the previous anonymous volume is left dangling, so it can still be recovered by hand, but docker volume prune would remove it.

Expected: run keeps the anonymous volumes of a recreated dependency, as up does.

Steps To Reproduce
services:
  app:
    image: alpine
    command: echo done
    depends_on: [db]
  db:
    image: alpine
    command: sleep infinity
    volumes:
      - /data          # anonymous volume
    environment:
      TAG: ${TAG:-one}
$ docker compose up -d db
$ docker compose exec db sh -c 'echo hello > /data/file'
$ TAG=two docker compose run --rm app       # db's config changed, so db is recreated
$ docker compose exec db cat /data/file
cat: can't open '/data/file': No such file or directory

With TAG=two docker compose up -d db instead of run, the last command prints hello.

Compose Version
Docker Compose version 5.0.1
Also reproduced on main (289d8a037).
Docker Environment
Docker Engine 29.1.3 (linux/arm64, Docker Desktop on macOS)
Anything else?

No response

主要语言
Go
星标
38.4k
派生
5.9k
平均合并
2 天 2 小时
30 天内合并 PR
66

环境准备

从这里开始

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

docker/compose 的其他 Issue

查看 docker/compose 的全部 Issue

相似的 Issue

更多 Go Issue

把新 issue 发到你的邮箱

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