Local docker daemon support for .dockerignore when using jibDockerBuild
See original GitHub issueEnvironment:
- Jib version: 1.8.0
- Build tool: Gradle 5.6.2
- OS: macOS Mojave
Description of the issue:
Docker CLI behavior excluding files and directories in .dockerignore:
Before the docker CLI sends the context to the docker daemon, it looks for a file named .dockerignore in the root directory of the context. If this file exists, the CLI modifies the context to exclude files and directories that match patterns in it. This helps to avoid unnecessarily sending large or sensitive files and directories to the daemon and potentially adding them to images using ADD or COPY.
The FAQ suggests using jibDockerBuild to build directly to local Docker daemon
jibDockerBuild for Gradle to build directly to your local Docker daemon.
Expected behavior: Expecting files in the .dockerignore file (located at the root folder of the project) to not be included in the docker image.
Alternatively, it would be nice to offer an option for excluding files when configuring jib.
Steps to reproduce:
- Set up build.gradle
- create somefile.text in root project folder
- create .dockerignore
somefile.txt
- Run
gradle jibDockerBuild
jib-gradle-plugin
Configuration:
jib.to.image = "test-image"
jib.from.image = 'gcr.io/distroless/java:11'
Additional Information: Using dive to inspect the image includes files which should have been ignored.
Issue Analytics
- State:
- Created 4 years ago
- Comments:7 (3 by maintainers)
Top GitHub Comments
@gataela one option is to use the layer-filter extension.
That works for me. Thanks for the help.