Skip to content

Build image from github repo and Dockerfile in a subdirectory #2119

Closed
@nilevols

Description

@nilevols

Description

version: docker-java-core:3.3.0

I'm using the build api to build from a github repo, the build context is the repo root, but the Dockerfile is in a subdirectory. So I need to with both remote and dockerFilePath to the DockerClient.

client.buildImageCmd()
         .withRemote(new URI("https://github.com/hyperledger/fabric.git#v2.2.5"))
         .withDockerfilePath("images/peer/Dockerfile")

This would fail
with the error Status 500: {"message":"Cannot locate specified Dockerfile: Dockerfile"}

It works in the docker client:
image

And also works in the raw docker api:
image

As the logic in the codes below(tag 3.3.0), it seems cannot pass both remote and dockerfile param to the api.
https://github.com/docker-java/docker-java/blob/f306650d6d696b7abdf0f1c7cde423b2c1262993/docker-java-core/src/main/java/com/github/dockerjava/core/exec/BuildImageCmdExec.java#LL54C1-L55C1

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions