-
Notifications
You must be signed in to change notification settings - Fork 5.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a warning when up
builds and a --build
flag
#2601
Conversation
Oh, there are test failures on other hosts. I guess I had images built from previous runs that aren't being removed. |
up
if --build
flag is set
I've added some more context in the description about the tradeoffs and backwards compatibility. Feedback is appreciated so that we can get this into 1.6. |
We can partially mitigate this with a 2-step release plan: keep the current behaviour in 1.6, but show a warning on $ docker-compose up
WARNING: In the next version of Compose, services with a 'build' key will be built
every time you run `docker-compose up`. If you do not want this behaviour, use
`docker-compose up --no-build` or set COMPOSE_AUTO_BUILD=false.
Creating myapp_web_1
... (as demonstrated above, it might be nice to provide an environment variable too) |
What's the current state on this? My reason behind this can be summed up as "make it easy for new users to NOT shoot themselves in the foot when using the tool`; applied to the two alternatives "always build" vs. "never build", this means:
In my personal expirience, I use
I'd therefore argument for optimizing the most common use-case, which is rebuilding and recreating a container, as opposed to recreating a container based on a possible stale image. "Smart recreate" is not broken by building always
"Smart recreate" is not affected by building on every
has changed its contents, and thus no cached version is available. |
Not everyone uses Compose this way, and not necessarily even most people. It's a recommended practice to mount your application code in a volume so that you don't have to rebuild the image or even restart your container to pick up changes. So I'd argue that |
0b09c62
to
a6d06ed
Compare
Ok, this PR has been reworked. The description has been updated with the new behaviour, and the tests are passing.a It is ready for review. |
After thinking a bit about it, I think that I'd be happy with the behavior that is outlined in the PR description. This includes both the first-time warning on I'd addtionally suggest two things:
|
Sounds reasonable. The reason I went with this flag is because we can't just remove The |
As a counterweight to @cr7pt0gr4ph7's initial comment I never use Just like @aanand says the "right" way to work on changes within a container is with volume mounts. This is by far the quickest way to iterate. Once I'm done with that I do a It seems to me the change in this PR is a fair solution to these 2 points of view + solves the many questions/issues that are created because of unexpected behaviour of Regarding the actual argument to Also I'd suggest creating an issue to not forget to remove |
|
@dnephin wouldn't it make more sense to make |
That's what I wanted to do originally (see #693), but we came to a consensus with this approach instead. |
log.warn( | ||
"Image for service {} was build because it was not found. To " | ||
"rebuild this image you must use the `build` command or the " | ||
"--build flag.".format(self.name)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo: "was build" -> "was built"
Perhaps "because it did not already exist"?
Also, might be nice to specify the exact commands:
To rebuild this image, use
docker-compose build
ordocker-compose up --build
.
a6d06ed
to
e1b87d7
Compare
Fixed the warning test |
Also adds a warning when up builds an image without the --build flag so that users know it wont happen on the next up. Signed-off-by: Daniel Nephin <dnephin@docker.com>
Signed-off-by: Daniel Nephin <dnephin@docker.com>
LGTM |
Only build as part of `up` if `--build` flag is set
up
if --build
flag is setup
builds and a --build
flag
Fixes #693
Closes #12
Many users have been confused by the default build behaviour of
up
.This PR has been updated with the following behaviour:
--build
in the future--build
toup
andcreate
to allow images to be built with a single command