2

I am building a container using Jib's Maven plugin.

I have a file called /tmp/folder/file.json on my host machine, which I need to be able to read from inside a container.

I tried to mount /tmp/folder using the volumes feature:

  <plugin>
     <groupId>com.google.cloud.tools</groupId>
     <artifactId>jib-maven-plugin</artifactId>
     <version>1.0.0</version>
     <configuration>
       <to>
          <image>myimage</image>
       </to>
       <container>
           <volumes>
               <volume>/tmp/folder</volume>
           </volumes>
       </container>
      </configuration>
  </plugin>

I think /tmp/folder is accessible from the container but file.json isn't. At least when I try this

 docker exec -it my_cotainer /bin/ls /tmp/folder 

Nothing comes back.

Am I using the volumes feature correctly?

daphshez
  • 9,272
  • 11
  • 47
  • 65

1 Answers1

1

If you don't specify from property the default gcr.io/distroless/java image is used. You can execute /bin/ls using this image.

"Distroless" images contain only your application and its runtime dependencies. They do not contain package managers, shells or any other programs you would expect to find in a standard Linux distribution.

Try to build from linux based image.

  <plugin>
     <groupId>com.google.cloud.tools</groupId>
     <artifactId>jib-maven-plugin</artifactId>
     <version>1.0.0</version>
     <configuration>
       <from>
          <image>openjdk:8-jre-alpine</image>
       </from>
       <to>
          <image>myimage</image>
       </to>
       <container>
           <volumes>
               <volume>/tmp/folder</volume>
           </volumes>
       </container>
      </configuration>
  </plugin>
charlycou
  • 1,778
  • 13
  • 37