Skip to content

buildx bake: Specifying --file in another directory leads to failure #1028

Description

@sfgeorge

Behaviour

tl;dr I can get docker buildx bake to succeed only when I cd to the subdirectory where docker-compose.yml lives.

Steps to reproduce this issue

Given the following project directory structure:

tests/docker-compose.yml
tests/dockerfiles/debian8/Dockerfile
tests/dockerfiles/debian9/Dockerfile
tests/dockerfiles/debian10/Dockerfile

And the following tests/docker-compose.yml file

version: "3"
services:
  debian8:
    build: ./dockerfiles/debian8
    cap_add: [ALL]
  debian9:
    build: ./dockerfiles/debian9
    cap_add: [ALL]
  debian10:
    build: ./dockerfiles/debian10
    cap_add: [ALL]

When a build definition file is specified in a subdirectory of the project such as above

Then resolution of Dockerfiles fails:

docker buildx bake -f  tests/docker-compose.yml
[+] Building 0.0s (0/0)
error: unable to prepare context: path "dockerfiles/debian9" not found

Yes, there is an obvious workaround – Simply first change the working directory to be that of where the build definition file exists.

cd tests && docker buildx bake
cd tests && docker buildx bake
[+] Building 1.4s (23/23) FINISHED
# (output omitted)

However, this limits the utility of this tool, especially in places like https://github.com/docker/bake-action, where that workaround is not possible because the option to change directories is not provided.

Expected behaviour

docker buildx bake -f ./tests/docker-compose.yml should succeed, given the context in the scenario above.

Configuration

Activity

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

Metadata

Metadata

Assignees

Labels

Type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions