Skip to content

JKube is not picking docker credentials from ~/.docker/config.json file #2290

@anurag-rajawat

Description

@anurag-rajawat

Describe the bug

I have successfully configured my Docker credentials in the ~/.docker/config.json file. However, when I try to push an image to the Docker registry using the k8sPush task, the task fails with the error requested access to the resource is denied.

I have also tried hard-coding my Docker credentials in the build.gradle file. In this case, the build process works as expected.

Eclipse JKube version

1.13.1

Component

Kubernetes Gradle Plugin

Apache Maven version

None

Gradle version

other (please specify in additional context)

Steps to reproduce

  1. Login to docker using docker login
  2. Run ./gradlew bootJar k8sBuild k8sPush

Expected behavior

When JKube is used to push an image to a Docker registry, it should first look for Docker credentials in the ~/.docker/config.json file. If the credentials are found, JKube should use them to authenticate with the Docker registry and push the image successfully.

Runtime

minikube

Kubernetes API Server version

1.25.3

Environment

macOS

Eclipse JKube Logs

./gradlew bootJar k8sBuild k8sPush

> Task :k8sBuild
k8s: Using Dockerfile: /Users/anurag/Playground/catalog-service/Dockerfile
k8s: Using Docker Context Directory: /Users/anurag/Playground/catalog-service
k8s: Building container image in Kubernetes mode
k8s: [anuragrajawat/catalog-service:0.0.1-SNAPSHOT]: Created docker-build.tar in 65 milliseconds
k8s: [anuragrajawat/catalog-service:0.0.1-SNAPSHOT]: Built image sha256:590f4

> Task :k8sPush
k8s: Using Dockerfile: /Users/anurag/Playground/catalog-service/Dockerfile
k8s: Using Docker Context Directory: /Users/anurag/Playground/catalog-service
k8s: Target image 'docker.io/anuragrajawat/catalog-service:0.0.1-SNAPSHOT' already exists. Tagging of 'anuragrajawat/catalog-service:0.0.1-SNAPSHOT' will replace existing image
k8s: The push refers to repository [docker.io/anuragrajawat/catalog-service]
k8s: Tagged image 'docker.io/anuragrajawat/catalog-service:0.0.1-SNAPSHOT' won't be removed after tagging as it already existed

> Task :k8sPush FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':k8sPush'.
> Error in pushing image: Error while trying to push the image: Unable to push 'anuragrajawat/catalog-service:0.0.1-SNAPSHOT' to registry 'docker.io' : denied: requested access to the resource is denied

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 5s
6 actionable tasks: 6 executed

Sample Reproducer Project

https://github.com/anurag-rajawat/catalog-service

Additional context

Gradle version: 8.1.1

Metadata

Metadata

Labels

bugSomething isn't workingcomponent/gradle-pluginRelated to the Gradle Plugins

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions