jib: Invalid volume path when creating docker image using jib

365 Views Asked by At

I am using jib to build my spring boot war file for tomcat.

I am using a local tomcat docker image.

I use gradle jibDockerBuild --stacktrace and i get the following error:

caused by: com.google.cloud.tools.jib.image.json.BadContainerConfigurationFormatException: Invalid volume path: [
        at com.google.cloud.tools.jib.image.json.JsonToImageTranslator.volumeMapToSet(JsonToImageTranslator.java:268)
        at com.google.cloud.tools.jib.image.json.JsonToImageTranslator.configureBuilderWithContainerConfiguration(JsonToImageTranslator.java:201)
        at com.google.cloud.tools.jib.image.json.JsonToImageTranslator.toImage(JsonToImageTranslator.java:137)
        at com.google.cloud.tools.jib.builder.steps.LocalBaseImageSteps.lambda$returnImageAndRegistryClientStep$2(LocalBaseImageSteps.java:171)
        at com.google.cloud.tools.jib.builder.steps.StepsRunner.lambda$assignLocalImageResult$4(StepsRunner.java:289)
        at com.google.common.util.concurrent.TrustedListenableFutureTask$TrustedFutureInterruptibleTask.runInterruptibly(TrustedListenableFutureTask.java:125)
        at com.google.common.util.concurrent.InterruptibleTask.run(InterruptibleTask.java:69)
        at com.google.common.util.concurrent.TrustedListenableFutureTask.run(TrustedListenableFutureTask.java:78)

I am able to run the image with docker run and docker-compose.

Any ideas?

Thanks, B

1

There are 1 best solutions below

0
On

Your base tomcat image in the local Docker daemon has incorrect volume configuration values. We have seen the exact same case in the past.

got an older base image based on a older revision of centos/systemd where a volume is defined using [[ <volume-path> ]] pattern. this does not seem to work at all Is that supposed to be supported?

Caused by:
com.google.cloud.tools.jib.image.json.BadContainerConfigurationFormatException:
Invalid volume path: [

rebasing the image on the very latest centos/systemd seems to work where the same volume is defined as [ <volume-path> ]

In that case, docker inspect showed that Volumes was set to

"Volumes": {
    "[": {},
    "]": {},
    "“/sys/fs/cgroupâ€": {}
}

which is a map from string (volume path) -> literal {}, meaning that it defines three volume paths (map entries): [, ], “/sys/fs/cgroupâ€. And of course, ] and [ are not a valid absolute UNIX path.

A correct setting will look like

"Volumes": {
    "/my/volume/dir": {},
    "/another/volume": {}
},

where each entry is a map from an absolute UNIX path to {}.

Fixing the Volumes configuration of your tomcat image will resolve the issue.