Running container created by JIB image

1/14/2019

I am using maven jib plugin to dockerize my Spring boot based application.

https://github.com/GoogleContainerTools/jib/tree/master/jib-maven-plugin

<plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-resources-plugin</artifactId>
                        <executions>
                            <execution>
                                <phase>generate-sources</phase>
                                <goals>
                                    <goal>copy-resources</goal>
                                </goals>
                                <configuration>
                                    <resources>
                                        <resource>
                                            <directory>src/main/resources/static</directory>
                                        </resource>
                                    </resources>
                                    <outputDirectory>${project.build.directory}/webapp/static</outputDirectory>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>com.google.cloud.tools</groupId>
                        <artifactId>jib-maven-plugin</artifactId>
                        <version>0.9.13</version>
                        <executions>
                            <execution>
                                <phase>package</phase>
                                <goals>
                                    <goal>build</goal>
                                </goals>
                            </execution>
                        </executions>
                        <configuration>
                            <from>
                                <image>${base.image}</image>
                            </from>
                            <to>
                                <image>${registry}/${repository}/${image}:${version}</image>
                            </to>
                            <extraDirectory>${project.build.directory}/webapp</extraDirectory>
                        </configuration>
                    </plugin>

I use the following command to run in Kubernetes. Snippet from Kubernetes deployment yaml file.

- args:
    - -c
    - java -cp /app/libs/*:/app/resources/:/app/classes/ -Xmx2g -Xms2g com.test.Application
      --spring.config.location=/config/application.properties
    command:
    - /bin/sh
    image: ....

It runs fine. I am confused on running the samething using docker.

I tried the below command, But, it is not picking the applicaiton.properties file. I have my application.properties under /local/path/config folder.

docker run IMAGE /bin/bash -c "java -cp /app/libs/*:/app/resources/:/app/classes/ -Xmx2g -Xms2g com.test.Application --spring.config.location=/config/application.properties" -v /local/path/config:/config/

-- user1578872
docker
jib
kubernetes

0 Answers