4

When I try to docker-compose up with one of my images missing, I get:

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

I understand from the documentation that this is indeed what the --no-build option does:

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

Why is this default behavior and how can my docker-compose up automatically trigger a docker-compose build beforehand?

1 Answer 1

2

This is monitored by issue 1679: "docker-compose up assumes --no-build"

The crux of the problem is:

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 adds:

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.

Sign up to request clarification or add additional context in comments.

1 Comment

Ok thanks! I'll follow up on that thread. I'm wondering though why there isn't simply a --force-build option just like there's a --force-recreate option (reference)..

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.