FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Error during image build when Dockerfile in subdirectory of build context · Issue #551 · docker-java/docker-java · GitHub

Repository navigation

Error during image build when Dockerfile in subdirectory of build context #551

Closed

Description

Hello!

I try to build docker image with your library and think I found a bug.
I have such project structure:

/path/to/project/docker/Dockerfile
/path/to/project/target/app.jar

In my Dockerfile:

(...)
COPY target/app.jar /opt/app/app.jar
(...)

I try to build image with code:

final String baseDirectory = "/path/to/project";
final String dockerfile = baseDirectory + "/docker/Dockerfile";
dockerClient.buildImageCmd()
                .withBaseDirectory(new File(baseDirectory))
                .withDockerfile(new File(dockerfile))
                .exec()
                .awaitImageId();

I get error: Could not build image: lstat target/app.jar: no such file or directory

I think there is bug in class Dockerfile.
In method processAddStatement() is line

src = new File(dockerFolder, resource);

and dockerFolder is parent directory of Dockerfile. IMO it is incorrect, it should be

src = new File(baseDirectory, resource);

where baseDirectory is directory passed to method withBaseDirectory() of BuildImageCmd.

From command line build works with command

docker build -f docker/Dockerfile .

Activity

  1. KostyaSha commented on Apr 18, 2016

    Member

    please provide PR

    Sent from my iPad

    On Apr 18, 2016, at 1:57 PM, osek666 notifications@github.com wrote:

    Hello!

    I try to build docker image with your library and think I found a bug.
    I have such project structure:

    /path/to/project/docker/Dockerfile
    /path/to/project/target/app.jar
    In my Dockerfile:

    (...)
    COPY target/app.jar /opt/app/app.jar
    (...)
    I try to build image with code:

    final String baseDirectory = "/path/to/project";
    final String dockerfile = baseDirectory + "/docker/Dockerfile";
    dockerClient.buildImageCmd()
    .withBaseDirectory(new File(baseDirectory))
    .withDockerfile(new File(dockerfile))
    .exec()
    .awaitImageId();
    I get error: Could not build image: lstat target/app.jar: no such file or directory

    I think there is bug in class Dockerfile.
    In method processAddStatement() is line

    src = new File(dockerFolder, resource);
    and dockerFolder is parent directory of Dockerfile. IMO it is incorrect, it should be

    src = new File(baseDirectory, resource);
    where baseDirectory is directory passed to method withBaseDirectory() of BuildImageCmd.

    From commandline build works with command

    docker build -f docker/Dockerfile .
    —
    You are receiving this because you are subscribed to this thread.
    Reply to this email directly or view it on GitHub

  2. added 3 commits that reference this issue on May 11, 2016
  3. changed the title [-]Error during image build[/-] [+]Error during image build when Dockerfile in subdirectory of build context[/+] on May 12, 2016
  4. marcuslinke commented on May 12, 2016

    Contributor

    Closed via #578

  5. added 2 commits that reference this issue on Aug 20, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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


      Back | FazBrowse Home | New Git URL