question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Local docker daemon support for .dockerignore when using jibDockerBuild

See original GitHub issue

Environment:

  • 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:

  1. Set up build.gradle
  2. create somefile.text in root project folder
  3. create .dockerignore
somefile.txt
  1. 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:closed
  • Created 4 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
chanseokohcommented, Jan 4, 2022

@gataela one option is to use the layer-filter extension.

1reaction
reevesmcommented, Dec 12, 2019

That works for me. Thanks for the help.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Jib vs. Spring Boot for building Docker images - Tom Gregory
Running Jib with Docker daemon. Given this configuration, we can execute the jibDockerBuild task, which builds the image using the local Docker ...
Read more >
10 best practices to build Java containers with Docker - Snyk
Let me help you out with this one! In the following cheatsheet, I will provide you with best practices to build a production-grade...
Read more >
How to build the docker image using jib-maven-plugin, but not ...
I just want to build the image locally and run it. I don't want to build and push to docker registry in one...
Read more >
Comparing Modern-Day Container Image Builders: Jib ...
First, we will try to build and publish the image to the local Docker daemon. Let's start the build with mvn spring-boot:build-image Maven...
Read more >
JIB – Build Docker images for your Java Application without a ...
Do you use Docker on your system to build images for your Java ... I had problems configuring and/or starting up the daemon...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found