-
Notifications
You must be signed in to change notification settings - Fork 5.2k
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
build not follow the order specified #5228
Comments
Hi @vochicong Thank you for your report. We don't consider this to be a bug. Is this causing issues with your application? |
Hi @shin- . Yes, I have
|
Ok, one simple solution would be to run |
@shin- I would like to re-open this, I am following multi stage builds that depends on another multi stage builds (micorservices). I would like the docker compose to build in the order specified , so that we build our common base first, then depends all our services on top of this. If the common base image exists already, compose skips it even though the Dockerfile for the base image have been changed, and the dependent images use the old image, literally wanting me to run compose twice. (BTW i dont want to use a script that builds it as compose definition is super easy to pass metadata as env variables during build). |
Users would expect that docker compose builds images in the order specified. |
I run into the same problem but solved by reordering the service definitions in docker-compose.yaml file. docker-compose follows the service order defined in that file. See: Lines 182 to 183 in e9220f4
|
For me, the ordering in the docker-compose.yaml file worked until a recent update to docker. It now builds the services in parallel (See the default value to the I'll have to rely on a script to build each service individually. 😞 Multi-stage build is probably the best and most correct solution, but for some, it isn't quite enough. For me, the reasons are as follows:
|
Seconding what @grahamaj said. I have a compose file with three services (A, B, and C). All have separate Dockerfiles in their own directories ( FROM A and C contains a line like: COPY --from=A /some/directory /some/directory Meanwhile, services:
A:
build:
context: ./a_dir
B:
build:
context: ./b_dir
C:
build:
context: ./c_dir Now, suppose that I make a change to A's Dockerfile which modifies I originally used a multi-stage file with So, I can of course build them in order manually. But my scripts which used to be able to simply use A lot of threads on StackOverflow as well as issues in this repo seem to be under the impression that |
I would be happy with a |
Any update? I'm having a similar issue https://stackoverflow.com/questions/73677392/how-to-force-docker-compose-to-wait-for-one-build-to-complete-before-building-an |
@shin-, could we reopen the ticket? It still exists. |
Seconded. Having the same problem, and the ability to force docker NOT to parallelize certain build steps would be very useful. (And also seems like a requirement for sanely implementing parallelism-by-default in the first place.) |
Same issue where I have 2 services built using their own The At first implementation it worked on Docker Compose v1, then, with v2, I had issues with Docker trying to pull image
services:
# Special service to build an image (named "my-shared-image") once for
# other services to use.
_shared_builder:
build:
context: .
dockerfile: ./my-shared-image.Dockerfile
command: "echo Build is done"
image: "my-shared-image"
pull_policy: never
restart: "no"
service-a:
build:
args:
- DOCKER_BASE_IMAGE=my-shared-image
context: .
dockerfile: ./service-a.Dockerfile
depends_on:
- _shared_builder
pull_policy: never
service-b:
build:
args:
- DOCKER_BASE_IMAGE=my-shared-image
context: .
dockerfile: ./service-b.Dockerfile
depends_on:
- _shared_builder
pull_policy: never
ARG DOCKER_BASE_IMAGE
FROM ${DOCKER_BASE_IMAGE}
RUN echo "I am service A."
ARG DOCKER_BASE_IMAGE
FROM ${DOCKER_BASE_IMAGE}
RUN echo "I am service B." Running docker-compose build --no-cache _shared_builder && \
docker-compose up -d --force-recreate --build |
This issue is quite old, but I would like to toss my hat in favor of some mechanism of build dependencies. My proposal is a |
Please reopen this, proposal from above makes sense and would help a lot. |
I hope someone breaks your dependencies half as bad as you have broke my entire build chain. The work-around proposed below is absolutely asinine. I'd have to manually write 30-40 build commands, instead of giving users the ability to manually set a build order. I'd be fired for something this short-sighted.
|
I believe this is a good solution, I'm trying to build a container based on another and docker always ignores despens_on and builds in the wrong order. |
docker-compose build
does not follow the order in which the services are specified.
will actually try to build in the order
base
,dev
andprod
,which is alphabetical order and not the order specified on the command line.
The text was updated successfully, but these errors were encountered: