testcontainers / testcontainers/testcontainers-java

.dockerignore file is not honored by ImageFromDockerfile

Open
#1,534 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

resolution/acknowledged type/bug
Dominant language
Java
Stars
8.7k
Forks
1.9k
Avg merge
2d 17h
Merged PRs (30d)
9

Description

For Docker build performance, it can be very important for certain projects to have a .dockerignore file so that extra content is not sent to the Docker daemon (which may be on a different machine).

It appears that the underlying docker-java API does support .dockerignore files:
https://github.com/docker-java/docker-java/blob/master/src/test/java/com/github/dockerjava/cmd/BuildImageCmdIT.java#L176

However, if I try an invalid .dockerignore in one of my Testcontainers projects, then it does not appeared to be honored. I was able to confirm this with the following steps:

  1. Add invalid content in a .dockerignore file like this:
*~
[a-b-c]
  1. Run docker build . and verify it fails
  2. Run equivalent command through TC API and it passes (it should fail due to invalid syntax)
new ImageFromDockerfile()
                        .withFileFromPath(".", Paths.get(".")))

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at ImageFromDockerfile and compare its file-transfer behavior with the docker-java BuildImageCmdIT.java test linked in the issue. Reproduce the invalid .dockerignore example through both docker build . and the Testcontainers API. Done means the API honors .dockerignore syntax and rejects the invalid pattern as Docker does.

Written by the indexing model from the issue text.

Assessment

Tech stack
docker, java
Domain
devops, testing
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.