0

I have a parent pom written by someone else, it is used for building and running a docker image locally. When I am trying to build using parent pom.xml, I am getting following error '~/.m2' cannot be relativized, cannot resolve arbitrary user home paths. I think the error is with bind volumes to the image. This is how it is defined in parent pom.xml

<volumes>
  <bind>
    <volume>${session.executionRootDirectory}:${session.executionRootDirectory}</volume>
    <!-- Mounts the Maven repository so that the Docker container doesn't have to re-download dependencies. -->
    <volume>~/.m2:/root/.m2</volume>
 </bind>
</volumes>

The above project is building fine on mac os, and I am using a windows machine. I installed docker for windows and read the fabric8 documentation, to know how to bind volumes to your image but could not find any example related to my issue.

user871611
  • 3,307
  • 7
  • 51
  • 73
Onix
  • 101
  • 1
  • It's using a *NIX path referring to the user's home directory `~`. On Windows that surely won't work, no. You'll have to replace that to the correct path to maven's `.m2` repo directory on your system. – Kayaman Sep 04 '19 at 07:26
  • yeah if I change it to C:\Users\\.m2 this error resolves, but the other volume to be mounted gives ` Mount denied: The source path "C:/path/to/current/project/directory:C" doesn't exist and is not known to Docker (Internal Server Error: 500)]` I think it is because the image is built using oracle linux and I the path ${session.executionRootDirectory} resolves to 'C:' so it is giving this error. What should I mention instead of ${session.executionRootDirectory} after ':' in 1st ? – Onix Sep 04 '19 at 08:07
  • It should be a *NIX path inside the container, so `/something`. – Kayaman Sep 04 '19 at 08:13

0 Answers0