GoogleContainerTools / jib

🏗 Build container images for your Java applications.
Apache License 2.0
13.61k stars 1.43k forks source link

Error 401 using Jib. #3989

Closed teem001 closed 6 months ago

teem001 commented 1 year ago

Environment:

Description of the issue:

Expected behavior:

Steps to reproduce:

jib-maven-plugin Configuration:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>org.olayinka.app</groupId>
    <artifactId>olayinka-microservice</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>pom</packaging>
    <modules>
        <module>customer</module>
        <module>notification</module>
        <module>fraud</module>
        <module>eureka-server</module>
        <module>client</module>
        <module>apigw</module>
        <module>amqp</module>
    </modules>

    <properties>
        <maven.compiler.source>17</maven.compiler.source>
        <maven.compiler.target>17</maven.compiler.target>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <release.train>2.7.8</release.train>
        <spring.boot.maven.version>2.7.8</spring.boot.maven.version>
        <spring.cloud.dependencies.version>2020.0.3</spring.cloud.dependencies.version>
        <image>teem001/${project.artifactId}:${project.version}</image>
    </properties>
    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-dependencies</artifactId>
                <version>${release.train}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-dependencies</artifactId>
                <version>${spring.cloud.dependencies.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-openfeign</artifactId>
        </dependency>
    </dependencies>

    <build>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-maven-plugin</artifactId>
                    <version>${spring.boot.maven.version}</version>
                    <executions>
                        <execution>
                            <goals>
                                <goal>
                                    repackage
                                </goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>
                <plugin>
                    <groupId>com.google.cloud.tools</groupId>
                    <artifactId>jib-maven-plugin</artifactId>
                    <version>3.3.1</version>
                    <configuration>
                        <from>
                            <image>eclipse-temurin:17</image>
                            <platforms>
<!--                                <platform>-->
<!--                                    <architecture>x64</architecture>-->
<!--                                    <os>linux</os>-->
<!--                                </platform>-->
                                <platform>
                                    <architecture>arm64</architecture>
                                    <os>linux</os>
                                </platform>
                                <platform>
                                    <architecture>amd64</architecture>
                                    <os>linux</os>
                                </platform>
                            </platforms>
                        </from>
                        <to>
                            <tags>
                                <tag>latest</tag>
                            </tags>
                        </to>
                    </configuration>
                    <executions>
                        <execution>
                            <phase>package</phase>
                            <goals>
                                <goal>build</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>
            </plugins>
        </pluginManagement>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.8.0</version>
                <configuration>
                    <source>17</source>
                    <target>17</target>
                </configuration>
            </plugin>
        </plugins>
    </build>

</project>

<!-- for one of the module -->
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.olayinka.app</groupId>
        <artifactId>olayinka-microservice</artifactId>
        <version>1.0-SNAPSHOT</version>
    </parent>

    <artifactId>apigw</artifactId>
    <packaging>jar</packaging>

    <properties>
        <maven.compiler.source>17</maven.compiler.source>
        <maven.compiler.target>17</maven.compiler.target>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>
    <profiles>
        <profile>
            <id>build-docker-image</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>com.google.cloud.tools</groupId>
                        <artifactId>jib-maven-plugin</artifactId>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>
<!--    <build>-->
<!--        <plugins>-->
<!--            <plugin>-->
<!--                <groupId>com.springframework.boot</groupId>-->
<!--                <artifactId>spring-boot-maven-plugin</artifactId>-->
<!--            </plugin>-->
<!--        </plugins>-->
<!--    </build>-->
    <dependencies>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-gateway</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-sleuth</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-sleuth-zipkin</artifactId>
        </dependency>
    </dependencies>

</project>

jib-gradle-plugin Configuration:

PASTE YOUR build.gradle CONFIGURATION HERE

Log output: INFO] Scanning for projects... [INFO] [INFO] -----------------------< org.olayinka.app:apigw >----------------------- [INFO] Building apigw 1.0-SNAPSHOT [INFO] from pom.xml [INFO] --------------------------------[ jar ]--------------------------------- [INFO] [INFO] --- clean:3.2.0:clean (default-clean) @ apigw --- [INFO] Deleting /Users/decagon/Desktop/olayinka-microservice/apigw/target [INFO] [INFO] --- resources:3.3.0:resources (default-resources) @ apigw --- [INFO] Copying 2 resources [INFO] [INFO] --- compiler:3.8.0:compile (default-compile) @ apigw --- [INFO] Changes detected - recompiling the module! [INFO] Compiling 1 source file to /Users/decagon/Desktop/olayinka-microservice/apigw/target/classes [INFO] [INFO] --- resources:3.3.0:testResources (default-testResources) @ apigw --- [INFO] skip non existing resourceDirectory /Users/decagon/Desktop/olayinka-microservice/apigw/src/test/resources [INFO] [INFO] --- compiler:3.8.0:testCompile (default-testCompile) @ apigw --- [INFO] Nothing to compile - all classes are up to date [INFO] [INFO] --- surefire:3.0.0-M8:test (default-test) @ apigw --- [INFO] No tests to run. [INFO] [INFO] --- jar:3.3.0:jar (default-jar) @ apigw --- [INFO] Building jar: /Users/decagon/Desktop/olayinka-microservice/apigw/target/apigw-1.0-SNAPSHOT.jar [INFO] [INFO] --- spring-boot:2.7.8:repackage (default) @ apigw --- [INFO] Replacing main artifact with repackaged archive [INFO] [INFO] --- jib:3.3.1:build (default) @ apigw --- [INFO] [INFO] Containerizing application to teem001/apigw:1.0-SNAPSHOT, teem001/apigw... [WARNING] Base image 'eclipse-temurin:17' does not use a specific image digest - build may not be reproducible [INFO] Using credentials from for teem001/apigw:1.0-SNAPSHOT [INFO] The base image requires auth. Trying again for eclipse-temurin:17... [WARNING] The credential helper (docker-credential-desktop) has nothing for server URL: registry-1.docker.io [WARNING] Got output:

credentials not found in native keychain

[WARNING] The credential helper (docker-credential-desktop) has nothing for server URL: registry.hub.docker.com [WARNING] Got output:

credentials not found in native keychain

[INFO] Using credentials from Docker config (/Users/decagon/.docker/config.json) for eclipse-temurin:17 [INFO] Executing tasks: [INFO] [======= ] 22.9% complete [INFO] > building dependencies layer [INFO] [INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Total time: 18.025 s [INFO] Finished at: 2023-04-22T12:15:56+01:00 [INFO] ------------------------------------------------------------------------ [ERROR] Failed to execute goal com.google.cloud.tools:jib-maven-plugin:3.3.1:build (default) on project apigw: Build image failed, perhaps you should make sure your credentials for 'registry-1.docker.io/library/eclipse-temurin' are set up correctly. See https://github.com/GoogleContainerTools/jib/blob/master/docs/faq.md#what-should-i-do-when-the-registry-responds-with-unauthorized for help: Unauthorized for registry-1.docker.io/library/eclipse-temurin: 401 Unauthorized [ERROR] GET https://auth.docker.io/token?service=registry.docker.io&scope=repository:library/eclipse-temurin:pull [ERROR] {"details":"incorrect username or password"} [ERROR] -> [Help 1] [ERROR] [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. [ERROR] Re-run Maven using the -X switch to enable full debug logging. [ERROR] [ERROR] For more information about the errors and possible solutions, please read the following articles: [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

Additional Information:

chanseokoh commented 1 year ago

[ERROR] {"details":"incorrect username or password"}

I've seen this many times with Docker Hub. The error message is from Docker Hub, saying you provided wrong credentials.

Using credentials from Docker config (/Users/decagon/.docker/config.json) for eclipse-temurin:17

The username and password were retrieved from /Users/decagon/.docker/config.json. The file has wrong credentials, and you should fix it.

Note eclipse-temurin:17 is a public image, and you don't really need to log in to Docker Hub, if you prefer. In that case, deleting your credentials in the file can be another option: https://stackoverflow.com/questions/72277087/401-unauthorized-when-using-jib-to-create-docker-image

burkedavison commented 6 months ago

Closing this issue as answered.