0

My question is how to use docker container-built software&library in the host machine. A docker shipped library might be a dependence for other tool/library compilation. this question comes with me when I tried some open source projects, e.g., openj9.

For example, I built one openJ9 VM, a Java VM that is similar to the HotSpot JVM, in a docker container, following (building instruction). The process is OK, but the next problem is how I can config the container-built jvm, residing at ~/openj9-openjdk-jdk8/build/linux-x86_64-normal-server-release/ inside of container, in the eclipse that resides at host machine?

I might be in the wrong way in using docker, feeling there would be a potential conflict, as the container environment for container-built jvm possibly differ from the host machine environment.

So can anyone explain the right way to use container-build jvm for my eclipse in the host machine? Thanks

shijie xu
  • 1,975
  • 21
  • 52

1 Answers1

1

There are two distinct usage modes here. I'm not sure which one of these you're asking about. Maybe you're asking about both.

If you want to run the JVM inside of the container in which you built it, then you've got the same case as if you were running the JVM on a remote server and wanting to connect your local Eclipse to it. I use IntelliJ, which has a number of ways of letting you deploy to and debug remote Java programs or libraries. Whatever the right way to do this is in Eclipse, the same would apply to a Java program running in a local Docker container.

If you're talking about taking the JVM package you've built inside a container, pulling it out of the container, and running it on your local workstation, this will work just like any other case where you build an executable or library on one machine to be used on another. You'd have the best chance of doing this without complications if you were running the same basic OS in both environments, like say Ubuntu of similar versions both inside and outside the container. You wouldn't be able to build a JVM binary inside Ubuntu running in a Docker container, and then pull it out and run it on your Windows workstation hosting Docker.

Actually...I realize that there's a third option. If you want to run your Java program inside a Docker container, it may be that Eclipse has specific support for doing this...deploying to and running a Java program inside a Docker host running on the same workstation as Eclipse. It would be doing basically the same thing as it would be for a remote server, but it very well could streamline this use case knowing that you are targeting a local Docker container.

CryptoFool
  • 21,719
  • 5
  • 26
  • 44
  • Actually it is 2nd for my question, while the host environment and the container env have slightly different. For the 1st, I need to deploy my code into container first; So, which is the normal mode with docker? Add my code into container and launch it using docker-built tools, or pull it out and run it in a host machine with the same env? Thanks – shijie xu May 19 '19 at 03:47
  • What is it you're really trying to achieve? I don't think I understand. The interesting thing it seems is that you want/need to build your own JVM. Is that necessary? You really need that JVM and you can only get it in source form? If that's true then if you could have that JVM running either on your workstation or in Docker, which would you prefer? The easiest thing is going to be to keep everything in one place or another. Otherwise, you're just using the container to build the JVM, and I'd wonder why you can't build the JVM on your local machine. – CryptoFool May 19 '19 at 04:27
  • I was looking at Eclipse support for Docker. There are tools for managing containers, but they don't really give you anything you can't do at the command line. They just give you a nicer GUI. Debugging support seems to be via the first model I gave you. You run your Java application in the container with remote debugging set up on a port, you the map that port to a port on the host, and then you create an Eclipse remote debugging session that connects to "localhost:" where is the host port that you're mapping your Java app's debugger port to.... – CryptoFool May 19 '19 at 04:40
  • I built jvm myself inside docker, as I made some changes and want to verify whether my changes have effect on my project, which was written inside of eclispe in host machine.. – shijie xu May 19 '19 at 05:12
  • Probably best to build your java program on your host, then add installing your java program to your Dockerfile so that it copies over the app and then runs it. You could do this on top of the same Dockerfile that builds your JVM, as if you just add to that Dockerfile, Docker is smart enough to not redo the parts it has already done of building the JVM. – CryptoFool May 19 '19 at 05:14
  • I'd say just play around. None of this should take too much code or too much time. It will give you good experience with Docker. – CryptoFool May 19 '19 at 05:15