Maven jib:dockerBuild in Google Cloud Build fails
See original GitHub issueDescription of the issue:
Attempting to build and deploy a container from within Google Cloud Build.
jib:build
wants me to authenticate within the same project where GCB and GCR run. It feels wrong to attempt to add this so I am attempting to use jib:dockerBuild
.
- name: 'gcr.io/cloud-builders/mvn'
id: MVN_COMPILE
args: ['compile','jib:dockerBuild', '-Dmaven.test.skip=true', '-Ddocker.image.prefix=gcr.io/$PROJECT_ID', '-s', '.mvn/settings.xml']
images:
- 'gcr.io/$PROJECT_ID/my-company-project'
But I am getting an error that Google Cloud Build does not have a docker daemon running. I can run both the jib:build
and jib:dockerBuild
locally, but need the CI to work as a trigger in Google Cloud Builder.
Steps to reproduce:
Simply using Google cloud build via triggers or gcloud builds submit .
Environment:
jib-maven-plugin
Configuration:
<plugin>
<groupId>com.google.cloud.tools</groupId>
<artifactId>jib-maven-plugin</artifactId>
<version>1.0.0</version>
</plugin>
Log output:
Step #3 - "MVN_COMPILE": [ERROR] Failed to execute goal com.google.cloud.tools:jib-maven-plugin:1.0.0:dockerBuild (default-cli) on project my-company-project: Build to Docker daemon failed, perhaps you should make sure Docker is installed and you have correct privileges to run it -> [Help 1]
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:12 (11 by maintainers)
Top Results From Across the Web
error:Failed to execute goal com.google.cloud.tools:jib-maven ...
This is a "generic error message". My solution is: docker system prune. This clean the docker images/container and the build docker images ...
Read more >Troubleshooting build errors | Cloud Build Documentation
This page provides troubleshooting strategies as well as solutions for some common error messages that you might see when running a build.
Read more >google/jib - Gitter
... got this [ERROR] Failed to execute goal com.google.cloud.tools:jib-maven-plugin:0.10.1:build (default) on project fcq-api-launcher: Build image failed, ...
Read more >Jib Build - Skaffold
Skaffold requires using Jib v1.4.0 or later. Skaffold supports building with Jib. locally and; remotely on Google Cloud Build. Jib Maven and ...
Read more >Dockerizing Java Apps using Jib - Baeldung
We'll take a simple Spring Boot application and build its Docker image ... mvn compile com.google.cloud.tools:jib-maven-plugin:2.5.0:build ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
UPDATE: the following workarounds to sidestep the Docker credential issue are no longer needed in recent Jib versions.
obsolete workarounds
Another option is to have
docker-credential-gcr
on$PATH
by whatever means:or
Hi @dgvigil,
GCB recently dropped Docker from
gcr.io/cloud-builders/mvn
. In fact, now the image has essentially become the officialmvn
Docker Hub image. Therefore,jib:dockerBuild
no longer works.Rather,
jib:build
should just work and push the built image to the GCR. Unforunately, as you mentioned, you have an authentication issue withjib:build
on GCB (internal bug: 124388903).UPDATE: the following workaround for the authentication issue is no longer necessary with recent Jib versions. Note you can’t still do
jib:dockerBuild
ongcr.io/cloud-builders/mvn
, because the Maven image doesn’t have Docker installed.obsolete workaround
However, there is a bug that prevents
jib:build
from working. On GCB,/builder/home/.docker/config.json
, which holds the GCR credentials, is not being copied/linked into/root/.docker/config.json
.That said, one ugly workaround you can use is to link that file yourself. Something like
(I know this is not pretty. Should be unnecessary once the bug is fixed.)
Or,
Or, see https://github.com/GoogleContainerTools/jib/issues/1500#issuecomment-477364975.