Skip to content
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

recreate container when image or dockerfile is updated #1383

Closed
TomasTomecek opened this issue May 3, 2015 · 16 comments
Closed

recreate container when image or dockerfile is updated #1383

TomasTomecek opened this issue May 3, 2015 · 16 comments

Comments

@TomasTomecek
Copy link

I'm using compose during development and I find it super useful. The only thing is that it takes so long to rebuild my environment (app, db, redis, worker, worker management). My workflow is, that I update one of the services and want to do up right away. Unfortunately compose recreates all containers, not just the one I updated.

Do you think it would make sense, if:

  • compose would recreate containers which have updates images
  • compose would rebuild images which have updates dockerfiles

I'll gladly provide patch for this.

@aanm
Copy link

aanm commented May 3, 2015

@TomasTomecek I had the same idea a while back... See this moby/moby#11024

@TomasTomecek
Copy link
Author

@aanm you're right, idea is the same; except that I would like to have this implemented in compose, not engine.

@aanand
Copy link

aanand commented May 5, 2015

I agree this would be good; for now, you can explicitly name which services you want to recreate:

# recreate only 2 services
$ docker-compose up -d --no-deps SERVICE1 SERVICE2

# stream logs for all of them
$ docker-compose logs

@TomasTomecek
Copy link
Author

Aha, --no-deps, that's what I missed.

@aanand so if I created patch for this, would you merge it? (I would probably create new option for up)

@aanand
Copy link

aanand commented May 6, 2015

Let me make sure I understand what you're proposing.

compose would recreate containers which have updates images

This part I think I understand: if db has image: postgres:latest, then we ask the Docker API what the current image ID is for postgres:latest. If there are db containers with a different image ID, we recreate them.

This is sensible, but I'm basically already working on this as part of #1345. It'll eventually be the default behaviour of docker-compose up, although to begin with will probably be behind an experimental command-line flag.

compose would rebuild images which have updates dockerfiles

This is the part that needs better specifying. How will you detect that the Dockerfile has changed? Are any of the concerns raised about @aanm's proposal in moby/moby#11024 addressed?

@TomasTomecek
Copy link
Author

Compose would stat the dockerfile and if last modification is newer than creation time of the image, it would be recreated.

@dnephin
Copy link

dnephin commented May 16, 2015

You would need to get the modified time of every file in the build context as well.

@TomasTomecek
Copy link
Author

That's true. Maybe it could be configurable.

@prologic
Copy link

Hmm can't re just rebuild the image anyway and let the Docker cache take care of things? If nothing changed all instructions will hit the cache and the image will be unchanged.

@manojlds
Copy link

manojlds commented Dec 7, 2015

+1 to @prologic

@sharhalakis
Copy link

I'd suggest keeping the dockerfile, or a hash of it, somewhere, and comparing against that instead of using a plain stat()... if possible.

@dnephin
Copy link

dnephin commented Feb 3, 2016

Issue #12 or #693 should allow for a way to build on up.

Any improvements to the build need to be implemented in the engine (or possible the proposed builder that is being extracted from the engine). Once there is upstream support we can use it to conditionally build when the context has changed.

@shanewow
Copy link

+1

@plavreshin
Copy link

+1 would be very useful

@dnephin
Copy link

dnephin commented Mar 7, 2016

Does up --build (#2601) solve this?

@TomasTomecek
Copy link
Author

@dnephin I think so. Let's close this. I have to say that UX when respinning services improved greatly in last year.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

9 participants