You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using docker compose up (or watch), Compose first builds all required images and then starts containers for them. In some workloads, one container is ready to launch much earlier than another.
An example: a postgres container is ready almost immediately, while the backend container is still building. During development, it can be quite useful to already start working with the database.
Would it be possible to launch containers as soon as they are ready, not waiting for all images to be built first?
Some observations:
When one service depends_on another, it obviously must wait until the dependency is ready
This may not be a desirable behavior in production
This feature can be emulated by first starting the 'faster' services: docker compose up --wait database && docker compose up
The text was updated successfully, but these errors were encountered:
Would be a significant architectural change
Also to be considered: what would be expected if build fails ? Should the already running services be stopped (like when you hit Ctrl+C to stop a compose up command) ?
For the scenario you describe, it seems to me relying on watch feature with a rebuild strategy already covers your need: even first time you run compose up you'll need to wait for build to complete before you can access database, then changes made to your backend source code will trigger a rebuild and restart so you don't have to wait more than required
Yes I had a feeling this would not be an easy one, so I definitely don't expect anything unless it is useful for many people!
As said, I can mostly emulate this behavior by doing a smaller up before doing a full up (or watch), so that would solve my initial problem. Your suggestion of using the rebuild strategy doesn't completely cover it: if you open your laptop, do a git pull and then start watch, your colleagues could have changed a lot of code, so you may at any time face waiting for a rebuild that is out of your control.
That becomes especially aggravating when the changes are in a part you don't care about at that moment: you have 10 rebuilding containers, and you just want to work on that one container right now!
In any case, a workaround is available, but it could be more 'hands-off' by starting containers as soon as they are ready.
Some development containers have quite a long initialization phase: for example the Angular development server compiles source code on-the-fly (for hot-reloading support), but it can only start once the container starts. It would save quite some time if it could already start compiling even though some other services are still in the build phase.
Description
When using
docker compose up
(orwatch
), Compose first builds all required images and then starts containers for them. In some workloads, one container is ready to launch much earlier than another.An example: a postgres container is ready almost immediately, while the backend container is still building. During development, it can be quite useful to already start working with the database.
Would it be possible to launch containers as soon as they are ready, not waiting for all images to be built first?
Some observations:
depends_on
another, it obviously must wait until the dependency is readydocker compose up --wait database && docker compose up
The text was updated successfully, but these errors were encountered: