Skip to content

bake: build dependent images in order #952

@pxeger

Description

@pxeger

Suppose I have a/Dockerfile:

FROM debian
RUN date > /hello

and b/Dockerfile:

FROM pxeger/a
RUN date >> /hello

and docker-bake.json:

{
  "group": {
    "default": {
      "targets": ["a", "b"]
    }
  },
  "target": {
    "a": {
      "context": "a/",
      "tags": ["pxeger/a:latest"]
    }
    "b": {
      "context": "b/",
      "tags": ["pxeger/b:latest"]
    }
  }
}

Right now, if I run docker buildx bake, the image pxeger/a will be pulled from the registry before either image is built, even though the build process will produce an a. This means:

  • needless extra pulls are made
  • the final resulting containers cannot share all the layers of a, because b was built upon the old version of a
  • if a does not exist on the registry, the build will fail

There seems to be no workaround for this. Even if bake doesn't want to include a Dockerfile parser and dependency resolution algorithm, it would be good to at least be able to manually force a dependency build order. (changing the order of group.default.targets doesn't work).

Of course this somewhat reduces the possible parallelism because a and b can't be built at the same time now.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions