Docker 撰写“--未通过构建”

Docker compose "--no-build was passed"

当我尝试 docker-compose up 我的一张图片丢失时,我得到:

Service 'server' needs to be built, but --no-build was passed.

我从文档中了解到,这确实是 --no-build 选项的作用:

--no-build Don't build an image, even if it's missing

为什么会出现这种默认行为?我的 docker-compose up 如何预先自动触发 docker-compose build

这由 issue 1679 监控:“docker-compose 假设 --no-build

问题的症结在于:

if my image exists (because I ran docker-compose build before), but the referred Dockefile changes, up won't trigger an automatic rebuild?
It may be a misunderstanding, but I thought that up always rebuilds the image if the Dockerfile is out of sync with the image, unless --no-build is passed.

aanand 添加:

up only checks that the image exists, not that it's up-to-date.
There's actually no way to check that.

We've discussed alternative approaches, including always building and never building.