Bordor Turtle
Bordor Turtle

Reputation: 51

Pass docker directory as a maven parameter

I have a maven goal that requires the server home folder as a parameter. On my local i just do:

mvn test -Dserverhome=/Users/foo/MyServer

On the test machine, the server is inside a docker container. How do i point to my server directory that is inside a docker container?

Upvotes: 1

Views: 78

Answers (1)

VonC
VonC

Reputation: 1323115

You need to mount your host folder as a data volume

docker run -d -P --name aname -v /Users/foo/MyServer:/myserver yourImage

That way, your maven command can always be (within the container)

 mvn test -Dserverhome=/myserver

Because you trust that, at runtime, /myserver will have been associated with the right host folder.

Note that if you are using docker on Mac or Windows, /Users is already mounted (by VirtualBox and by boot2docker tinycore Linux), so you would not even need to declare the data volume.

Upvotes: 1

Related Questions