1

How should I set up this maven plugin when there is no access to the online docker registry to force use local resources only?

[ERROR] Failed to execute goal com.google.cloud.tools:jib-maven-plugin:1.4.0:dockerBuild (default-cli) on project mental: registry-1.docker.io: Temporary failure in name resolution: Unknown host registry-1.docker.io: Temporary failure in name resolution -> [Help 1]

the plugin conf is:

<plugin>
    <groupId>com.google.cloud.tools</groupId>
    <artifactId>jib-maven-plugin</artifactId>
    <configuration>
        <from>
            <image>adoptopenjdk:11-jre-hotspot</image>
        </from>
        <to>
            <image>mental:latest</image>
        </to>
        <container>
            <entrypoint>
                <shell>sh</shell>
                <option>-c</option>
                <arg>chmod +x /entrypoint.sh &amp;&amp; sync &amp;&amp; /entrypoint.sh</arg>
            </entrypoint>
            <ports>
                <port>8080</port>
            </ports>
            <environment>
                <SPRING_OUTPUT_ANSI_ENABLED>ALWAYS</SPRING_OUTPUT_ANSI_ENABLED>
                <JHIPSTER_SLEEP>0</JHIPSTER_SLEEP>
            </environment>
            <useCurrentTimestamp>true</useCurrentTimestamp>
        </container>
    </configuration>
</plugin>

UPD. After upgrading jib plugin to 1.61. and adding the docker:// before the image name, offline build is working, but I'm getting the below error at the output:

[INFO] --- jib-maven-plugin:1.6.1:dockerBuild (default-cli) @ mental ---
[WARNING] <container><useCurrentTimestamp> is deprecated; use <container><creationTime> with the value USE_CURRENT_TIMESTAMP instead
[WARNING] Setting image creation time to current time; your image may not be reproducible.
[INFO] 
[INFO] Containerizing application to Docker daemon as mental...
[INFO] 
[INFO] Container entrypoint set to [sh, -c, chmod +x /entrypoint.sh && sync && /entrypoint.sh]
[INFO] 
[INFO] Built image to Docker daemon as mental
[INFO] Executing tasks:
[INFO] [==============================] 100.0% complete
[INFO] 
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  09:30 min
[INFO] Finished at: 2019-09-28T19:02:35+03:00
[INFO] ------------------------------------------------------------------------
Exception in thread "Thread-5" Exception in thread "Thread-6" java.lang.NoClassDefFoundError: com/google/common/io/RecursiveDeleteOption
    at com.google.cloud.tools.jib.filesystem.FileOperations.lambda$deleteRecursiveOnExit$1(FileOperations.java:102)
    at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.ClassNotFoundException: com.google.common.io.RecursiveDeleteOption
    at org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy.loadClass(SelfFirstStrategy.java:50)
    at org.codehaus.plexus.classworlds.realm.ClassRealm.unsynchronizedLoadClass(ClassRealm.java:271)
    at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:247)
    at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:239)
    ... 2 more
java.lang.NoClassDefFoundError: com/google/common/io/RecursiveDeleteOption
    at com.google.cloud.tools.jib.filesystem.FileOperations.lambda$deleteRecursiveOnExit$1(FileOperations.java:102)
    at java.lang.Thread.run(Thread.java:748)
Eljah
  • 4,188
  • 4
  • 41
  • 85

1 Answers1

2

Seeing the config would help, but you can instruct jib via <configuration> to use local docker deamon as the source of the image by prepending the image name with docker:// like below (which btw requires plugin version 1.6.0+):

<configuration>
  <from>
    <image>docker://openjdk:alpine</image>
  </from>
  <!-- ... -->
</configuration>

HTH

diginoise
  • 7,352
  • 2
  • 31
  • 39
  • [ERROR] Failed to execute goal com.google.cloud.tools:jib-maven-plugin:1.4.0:dockerBuild (default-cli) on project mental: Invalid image reference docker://openjdk:alpine, perhaps you should check that the reference is formatted correctly according to https://docs.docker.com/engine/reference/commandline/tag/#extended-description [ERROR] For example, slash-separated name components cannot have uppercase letters: Invalid image reference: docker://openjdk:alpine [ERROR] -> [Help 1] – Eljah Sep 26 '19 at 11:21
  • I also pulled this image before I've started the build offline – Eljah Sep 26 '19 at 11:23
  • and also, in my initial config I just had plugin configured 2 times, and the first onw had no configuration and the second one was configured well: – Eljah Sep 26 '19 at 11:25
  • added to the main question text – Eljah Sep 26 '19 at 11:26
  • 1
    can you up the version to latest? did you try `docker://adoptopenjdk:11-jre-hotspot` ? – diginoise Sep 26 '19 at 13:05
  • yes, I tried docker://adoptopenjdk:11-jre-hotspot and got the same. Ok, thanks, will try with the latest plugin version. – Eljah Sep 26 '19 at 14:17
  • 2
    The URL-style references were added to Jib 1.6. Latest is release is 1.6.1. – Brian de Alwis Sep 26 '19 at 17:29
  • sorry, I have realized that actually all the time I tired the last version I was still on 1.4 as I have changed the wrong variable in my pom.xml. So after I have fixed this, I got the docker image being built offline. Thanks for your help so much! – Eljah Sep 28 '19 at 16:16
  • and only thin, that I'm getting exception printed to the output despite of build success – Eljah Sep 28 '19 at 16:17