skip to Main Content

I’ve managed to create a docker image. And under the Docker Container files section I am able to see the directory as is.

Docker Container file-structure image

My working directory : "usr/local/bin/ClientApp"

Dockerfile:

FROM openjdk:11
EXPOSE 8080
WORKDIR /usr/local/bin/ClientApp
ADD . .
ADD target/ClientApp-0.0.1-SNAPSHOT.jar .
ENTRYPOINT ["java", "-jar", "ClientApp-0.0.1-SNAPSHOT.jar"]

Build logs:

[+] Building 10.0s (9/9) FINISHED                                                                                                                                        docker:default
 => [internal] load build definition from Dockerfile                                                                                                                               0.0s
 => => transferring dockerfile: 214B                                                                                                                                               0.0s 
 => [internal] load .dockerignore                                                                                                                                                  0.0s 
 => => transferring context: 2B                                                                                                                                                    0.0s 
 => [internal] load metadata for docker.io/library/openjdk:11                                                                                                                      1.2s 
 => [1/4] FROM docker.io/library/openjdk:11@sha256:99bac5bf83633e3c7399aed725c8415e7b569b54e03e4599e580fc9cdb7c21ab                                                                0.0s
 => [internal] load build context                                                                                                                                                  0.1s 
 => => transferring context: 30.23kB                                                                                                                                               0.1s
 => CACHED [2/4] WORKDIR /usr/local/bin/ClientApp                                                                                                                                  0.0s 
 => [3/4] ADD . .                                                                                                                                                                  6.7s 
 => [4/4] ADD target/ClientApp-0.0.1-SNAPSHOT.jar .                                                                                                                                1.0s
 => exporting to image                                                                                                                                                             0.7s
 => => exporting layers                                                                                                                                                            0.7s 
 => => writing image sha256:f98263f732ad48664c0cb0fed8e0f4bee8ca5ee652c964c7d028be953a631cae                                                                                       0.0s
 => => naming to docker.io/library/client-publisher-image:latest                                                                                                                   0.0s 

Error:

Exception in thread "main" java.lang.reflect.InvocationTargetException
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:566)
        at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:49)
        at org.springframework.boot.loader.Launcher.launch(Launcher.java:108)
        at org.springframework.boot.loader.Launcher.launch(Launcher.java:58)
        at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:65)
Caused by: java.io.FileNotFoundException: srcmainresourcesanaplan-connector-393817-7f22b1ca301b.json (No such file or directory)
        at java.base/java.io.FileInputStream.open0(Native Method)
        at java.base/java.io.FileInputStream.open(FileInputStream.java:219)
        at java.base/java.io.FileInputStream.<init>(FileInputStream.java:157)
        at java.base/java.io.FileReader.<init>(FileReader.java:75)
        at connector.demo.clientapp.ClientAppApplication.main(ClientAppApplication.java:21)
        ... 8 more

I am new to docker, can someone please help me resolving this error

2

Answers


  1. Chosen as BEST ANSWER

    Thanks all, however, I managed to resolve the issue by providing the filepath as : "spring.cloud.gcp.credentials.location=classpath:/service-key.json" in application.properties.


  2. Try checking out the files inside the container yourself

    docker run --rm -it --entrypoint bash <docker-img>
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search