[BUG] `docker compose run` drops the anonymous volumes of a dependency it recreates
维护者通常 1 天内回复
评估
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 新手友好度
- 25/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 停滞
- 技术栈
- docker, docker-compose, go
- 领域
- devops, infrastructure
调研方向
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 内容生成。
描述
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
环境准备
- 提供 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
docker/compose 的其他 Issue
-
[BUG] `watch` rebuilds in an endless loop when the watched path contains `.git`可能已有人在做 @htoyoda18 今天认领。 未关闭kind/bug status/0-triage
难度 2/5 1-3 小时 新手友好度 70/100
docker/compose#14362 · 1 条评论 ·
维护者通常 1 天内回复
-
kind/feature status/0-triage
难度 5/5 一周以上 新手友好度 35/100
维护者通常 1 天内回复
-
Epic: Move service selection into the backend API instead of pre-filtering the project in the CLI未关闭
难度 5/5 一周以上 新手友好度 15/100
维护者通常 1 天内回复
-
Watch: exec mode可能已有人在做 @glours 于 8 天前认领。 未关闭kind/feature
docker/compose#14326 · 1 条评论 · 已指派 1 人 ·
维护者通常 1 天内回复
-
Restore build concurrency limit now that bake supports it可能已有人在做 @maxproske 于 4 天前认领。 未关闭kind/feature
难度 3/5 1-2 天 新手友好度 35/100
维护者通常 1 天内回复
相似的 Issue
-
bug
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 2 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 83/100
devlikeapro/waha#2322 ·
维护者通常 2 天内回复
-
validateDeclaredPath lets control characters through into the Gradle init script's Groovy literal未关闭agent-butler-finding agent-research bug ready-for-agent
难度 2/5 1-3 小时 新手友好度 78/100
jordansmall/spindrift#5821 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 75/100
维护者通常 1 天内回复
-
[rmqctl][Bug] Windows build script fails when the output directory is absent可能已有人在做 关联的 PR 仍在进行中或已合并。 未关闭
难度 2/5 1-3 小时 新手友好度 72/100
apache/rocketmq-dashboard#7243 ·
维护者通常 3 天内回复