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.

docker run failed

See original GitHub issue

Environment:

  • Jib version: 1.8.0
  • Build tool: Maven 3.6.1
  • OS: Mac 10.15.2

Description of the issue:

run jib-maven-plugin:1.8.0:dockerBuild in idea the image build successful but when I run this image, failed

Maybe the JDK configuration is wrong What should I do

Expected behavior: run success

Steps to reproduce:

  1. dockerBuild
  2. run image

jib-maven-plugin Configuration:

<plugin>
                <groupId>com.google.cloud.tools</groupId>
                <artifactId>jib-maven-plugin</artifactId>
                <version>1.8.0</version>
                <configuration>
                    <to>
                        <image>harbor.test.com/${project.parent.artifactId}/${project.artifactId}:${env}-${project.version}</image>
                    </to>
                    <from>
                        <image>openjdk:alpine</image>
                    </from>
                    <container>
                        <mainClass>com.test.auth.server.AuthServerApplication</mainClass>
                        <jvmFlags>
                            <jvmFlag>-Xms512m</jvmFlag>
                        </jvmFlags>
                        <ports>
                            <port>9082</port>
                        </ports>
                        <environment>
                            <TZ>Asia/Shanghai</TZ>
                        </environment>
                        <volumes>/tmp</volumes>
                        <useCurrentTimestamp>true</useCurrentTimestamp>
                        <labels>
                            <maintainer>jade</maintainer>
                        </labels>
                    </container>
                    <allowInsecureRegistries>true</allowInsecureRegistries>
                </configuration>
            </plugin>

Log output:

/Library/Java/JavaVirtualMachines/jdk1.8.0_221.jdk/Contents/Home/bin/java -Dvisualvm.id=2681117957594 -Dmaven.multiModuleProjectDirectory=/Users/jade/work/workspace/test/test-auth/test-auth-server -Dmaven.home=/Users/jade/work/software/apache-maven-3.6.1 -Dclassworlds.conf=/Users/jade/work/software/apache-maven-3.6.1/bin/m2.conf “-Dmaven.ext.class.path=/Applications/IntelliJ IDEA.app/Contents/plugins/maven/lib/maven-event-listener.jar” “-javaagent:/Applications/IntelliJ IDEA.app/Contents/lib/idea_rt.jar=50153:/Applications/IntelliJ IDEA.app/Contents/bin” -Dfile.encoding=UTF-8 -classpath /Users/jade/work/software/apache-maven-3.6.1/boot/plexus-classworlds-2.6.0.jar org.codehaus.classworlds.Launcher -Didea.version2019.3.1 -s /Users/jade/work/software/apache-maven-3.6.1/conf/settings.xml -DskipTests=true com.google.cloud.tools:jib-maven-plugin:1.8.0:dockerBuild -P dev [INFO] Scanning for projects… [WARNING] [WARNING] Some problems were encountered while building the effective model for com.test:test-auth-server:jar:1.0-SNAPSHOT [WARNING] ‘dependencyManagement.dependencies.dependency.(groupId:artifactId:type:classifier)’ must be unique: com.alibaba:fastjson:jar -> duplicate declaration of version 1.2.60 @ com.test:test-dependencies:1.0.2, /Users/jade/work/software/maven_repository/com/test/test-dependencies/1.0.2/test-dependencies-1.0.2.pom, line 3179, column 25 [WARNING] ‘dependencyManagement.dependencies.dependency.version’ for com.test.cloud:test-cloud-starter:jar is either LATEST or RELEASE (both of them are being deprecated) @ com.test:test-dependencies:1.0.2, /Users/jade/work/software/maven_repository/com/test/test-dependencies/1.0.2/test-dependencies-1.0.2.pom, line 3187, column 26 [WARNING] [WARNING] It is highly recommended to fix these problems because they threaten the stability of your build. [WARNING] [WARNING] For this reason, future Maven versions might no longer support building such malformed projects. [WARNING] [INFO] [INFO] ----------------------< com.test:test-auth-server >----------------------- [INFO] Building test-auth-server 1.0-SNAPSHOT [INFO] --------------------------------[ jar ]--------------------------------- Downloading from test: http://172.16.6.124:8044/nexus/repository/maven-public/com/test/test-auth-api/1.0.4-SNAPSHOT/maven-metadata.xml Downloaded from test: http://172.16.6.124:8044/nexus/repository/maven-public/com/test/test-auth-api/1.0.4-SNAPSHOT/maven-metadata.xml (772 B at 3.4 kB/s) Downloading from test: http://172.16.6.124:8044/nexus/repository/maven-public/com/test/cloud/test-cloud-starter/1.0.6-SNAPSHOT/maven-metadata.xml Downloaded from test: http://172.16.6.124:8044/nexus/repository/maven-public/com/test/cloud/test-cloud-starter/1.0.6-SNAPSHOT/maven-metadata.xml (780 B at 52 kB/s) Downloading from test: http://172.16.6.124:8044/nexus/repository/maven-public/com/test/test-utils/1.0-SNAPSHOT/maven-metadata.xml Downloaded from test: http://172.16.6.124:8044/nexus/repository/maven-public/com/test/test-utils/1.0-SNAPSHOT/maven-metadata.xml (760 B at 51 kB/s) Downloading from test: http://172.16.6.124:8044/nexus/repository/maven-public/com/test/test-base/1.0-SNAPSHOT/maven-metadata.xml Downloaded from test: http://172.16.6.124:8044/nexus/repository/maven-public/com/test/test-base/1.0-SNAPSHOT/maven-metadata.xml (588 B at 42 kB/s) [INFO] [INFO] — jib-maven-plugin:1.8.0:dockerBuild (default-cli) @ test-auth-server — [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 harbor.test.com/test-auth/test-auth-server:dev-1.0-SNAPSHOT… [WARNING] Base image ‘openjdk:alpine’ does not use a specific image digest - build may not be reproducible [INFO] Getting manifest for base image openjdk:alpine… [INFO] Building dependencies layer… [INFO] Building resources layer… [INFO] Building snapshot dependencies layer… [INFO] Building classes layer… [INFO] The base image requires auth. Trying again for openjdk:alpine… [INFO] Retrieving registry credentials for registry-1.docker.io… [WARNING] The credential helper (docker-credential-desktop) has nothing for server URL: registry-1.docker.io

Got output:

credentials not found in native keychain

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

Got output:

credentials not found in native keychain

[WARNING] The credential helper (docker-credential-desktop) has nothing for server URL: index.docker.io

Got output:

credentials not found in native keychain

[WARNING] The credential helper (docker-credential-desktop) has nothing for server URL: docker.io

Got output:

credentials not found in native keychain

[INFO] Using base image with digest: sha256:d4c84528b8de75bf40ef402e7b02ffe60c5ae834a702e510664be1f6fc03d510 [INFO] [INFO] Container entrypoint set to [java, -Xms512m, -cp, /app/resources:/app/classes:/app/libs/*, com.test.auth.server.AuthServerApplication] [INFO] Loading to Docker daemon… [INFO] [INFO] Built image to Docker daemon as harbor.test.com/test-auth/test-auth-server:dev-1.0-SNAPSHOT [INFO] [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 15.254 s [INFO] Finished at: 2020-01-14T09:34:38+08:00 [INFO] ------------------------------------------------------------------------

docker run log Exception in thread “main” java.lang.IllegalAccessError: tried to access method org.springframework.core.io.support.SpringFactoriesLoader.loadFactoryNames(Ljava/lang/Class;Ljava/lang/ClassLoader;)Ljava/util/List; from class org.springframework.boot.SpringApplication at org.springframework.boot.SpringApplication.getSpringFactoriesInstances(SpringApplication.java:418) at org.springframework.boot.SpringApplication.getSpringFactoriesInstances(SpringApplication.java:412) at org.springframework.boot.SpringApplication.<init>(SpringApplication.java:268) at org.springframework.boot.SpringApplication.<init>(SpringApplication.java:249) at org.springframework.boot.builder.SpringApplicationBuilder.createSpringApplication(SpringApplicationBuilder.java:104) at org.springframework.boot.builder.SpringApplicationBuilder.<init>(SpringApplicationBuilder.java:92) at com.test.auth.server.AuthServerApplication.main(AuthServerApplication.java:22)

Additional Information: host 172.16.5.111 harbor.test.com

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:10 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
loosebazookacommented, Jan 15, 2020

as @kan-izh said, it’s quite possible that the ordering of dependency loading is messing this up. Especially if this works locally.

Can you run

mvn dependency:copy-dependencies

inspect the copied dependencies by looking for SpringFactoriesLoader (assuming linux)

cd target/dependency
grep SpringFactoriesLoader.class -r *

presumably if the theory holds true, you will see more than one instance of this class in multiple jar files?

0reactions
chanseokohcommented, Dec 7, 2020

@SandNight @kan-izh we’ve released Jib 2.7.0 which added a new configuration option (jib.container.expandClasspathDependencies (Gradle) / <container><expandClasspathDependencies> (Maven)) that enables expanding classpath dependencies in the default java command for an image ENTRYPOINT. Turning on the option (off by default) will enumerate all the dependencies, which will match the dependency loading order in Maven or Gradle builds. For example, the ENTRYPOINT becomes

java ... -cp /app/resources:/app/classes:/app/libs/spring-boot-starter-web-2.0.3.RELEASE.jar:/app/libs/shared-library-0.1.0.jar:/app/libs/spring-boot-starter-json-2.0.3.RELEASE.jar:... com.example.Main

instead of the default

java ... -cp /app/resources:/app/classes:/app/libs/* com.example.Main

Expanding the dependency list can be useful in AppCDS too.

Note that an expanded dependency list can become very long in practice, and we are not sure if there may be a potential issue due to a long command line (“argument list too long” or “command line is too long”).

As with other Jib configurations, this option can also be set through the system property (-Djib.container.expandClasspathDependencies=true|false).

Read more comments on GitHub >

github_iconTop Results From Across the Web

Docker run failed to run the container - Stack Overflow
I am able to build my docker based on below Dockerfile. ... It's failing and exits while is trying to run the container...
Read more >
How to Fix and Debug Docker Containers Like a Superhero
Use docker run to spin up a container v7 from the original entrypoint , which may work briefly but soon stop running. Inspect...
Read more >
How can I debug a docker container initialization? - Server Fault
First start docker events in the background to see whats going on. docker events&. Then run your failing docker run ... command. Then...
Read more >
6 ways to debug an exploding Docker container - Medium
Fortunately, there's a workaround: save the current state of the shut-down container as a new image, and start that with a different command...
Read more >
Docker Container Run Fails · Issue #1118 - GitHub
While executing the docker container, the following error were observed. ‹master*› » docker run -it -e AWS_SECRET_ACCESS_KEY_ID=xxxxxxxxxxxx ...
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