0

It's probably too soon to ask this question but I hope someone has already had the same problem as me.

I have to build a jar that run on a centos7, openjdk-7 machine.

I created a docker machine in a ridiculously short time :) but my issue is more a maven one.

My questions is :

How to generate a jar on remote machine (container powered by kitematic on mac for example :p) with the jdk and environment of this machine ?

Any help we'll be welcome.

--- EDIT

I develop on my mac and I would like to launch the build on a "remote" machine which is, in local, my docker container on the kitematic vm.

Thomas Leduc
  • 1,092
  • 1
  • 20
  • 44
  • I'm not sure what you're asking? What's to stop you building a Jar in a centos7 container? – Adrian Mouat Mar 20 '15 at 12:14
  • Oh sorry, I completely missing the point : I develop on my mac. I edit the question, thx for pointing this. – Thomas Leduc Mar 20 '15 at 13:12
  • I'm still lost. Are you looking for `docker exec`? Normally you would just do `docker run mycentos mvn command`, probably mapping in a volume to hold the output. Does that help?! – Adrian Mouat Mar 20 '15 at 13:46
  • Nope, sorry it's probably me but The code is somewhere (like on my mac) and the environment and jdk is somewhere else (like in a container). The ultimate goal would be to create an integration process. – Thomas Leduc Mar 20 '15 at 14:14
  • You can mount the code from the Mac into docker container using volumes and use the JDK in the container to compile it. Is that what you're trying to do? It's very hard to understand what you are trying to do and why you think it doesn't work. – Adrian Mouat Mar 20 '15 at 14:20
  • I simply want that I want do a `mvn compile` the code is compiled on the remote machine but not on mine, where I'm coding and the code actually is. I could make a sshfs mount or something like this to host the code in the container but I would like to properly do that. – Thomas Leduc Mar 20 '15 at 16:15
  • What does "to properly do that" mean? You don't need sshfs mount or anything, it should just work out of the box. I'm lost. – Adrian Mouat Mar 20 '15 at 16:29
  • possible duplicate of [How to dockerize maven project? and how many ways to accomplish it?](http://stackoverflow.com/questions/27767264/how-to-dockerize-maven-project-and-how-many-ways-to-accomplish-it) – Mark O'Connor Mar 20 '15 at 20:27

1 Answers1

0

I think you're just asking how to compile source on your local Mac using a container. If you have boot2docker installed, the following works:

$ docker run -v $(pwd)/java_proj:/java_proj java:openjdk-7u65-jdk javac /java_proj/Test.java

Assuming you have a folder java_proj in your current directory with the file Test.java, this will compile the test file and should place the output in the same folder. We can do this as the boot2docker VM shares your home directory and we can then mount the folder as a volume inside the container. The code will be compiled using the compiler and environment of the java:openjdk-7u65-jdk image.

Adrian Mouat
  • 44,585
  • 16
  • 110
  • 102
  • I didn't understand when I first read your answer, but it's totally what I was looking for. The `-v` option is the key. Thank you. – Thomas Leduc Mar 20 '15 at 20:34