JRebel for Cloud in Docker¶
JRebel remote server functionality is available for virtual machines running on Docker. The following details need to be kept in mind when running JRebel with Docker.
The Docker container needs to include the JRebel Agent and its platform-specific library. You can download JRebel from the products download page. There is a convenience download URL https://dl.zeroturnaround.com/jrebel-stable-nosetup.zip that points to the latest stable JRebel release archive.
You need to enable JRebel for the application server in Docker. Add
-agentpath:/[JRebel library]and-Drebel.remoting_plugin=trueto the startup parameters. You will need to replace the library placeholder with the correct operating system and 32 or 64 bit library:Windows 64-bit JDK
-agentpath:[c:\path\to]jrebel64.dllWindows 32-bit JDK
-agentpath:[c:\path\to]jrebel32.dllMac OS X 64-bit JDK
-agentpath:[path/to]libjrebel64.dylibMac OS X 32-bit JDK
-agentpath:[path/to]libjrebel32.dylibLinux 64-bit JDK
-agentpath:[path/to]libjrebel64.soLinux 32-bit JDK
-agentpath:[path/to]libjrebel32.soThe JRebel IDE plugin and project need to be configured with the remote server information. You need to enable remote server support for the project and configure the JRebel IDE plugin to connect to the Docker server. For more information, refer to remote server overview.
Tip
Refer to the running servers from command line chapter to learn more about adding JRebel to various application servers.
Example for JRebel with Dockerfile and Tomcat 9.0 (Linux 64-bit)¶
Extract
jrebel.jarand thelibfolder from the root of the downloaded archive. Copy these files to the folder that you will use to generate the image.Create a new
Dockerfilein the same folder with the following content:
FROM tomcat:9.0 COPY jrebel.jar /jrebel.jar COPY lib/libjrebel64.so /lib/libjrebel64.so ENV JAVA_OPTS="-agentpath:/libjrebel64.so -Drebel.remoting_plugin=true -Drebel.log.file=/jrebel.log"
Save your
Dockerfile.Build your Docker image.
$ docker build -t [desired image title] .
Run your Docker container!
To use remote server functionality, add your Docker server address to your IDE workspace for synchronization.
Example for JRebel with Docker Compose and Tomcat 9.0 (Linux 64-bit)¶
Extract
jrebel.jarand thelibfolder from the root of the downloaded archive. Copy these files to the folder that you will use to generate the container.Create a new
docker-compose.ymlor add to an existingdocker-compose.ymlthe following content:
container-name: image: tomcat:9.0 volumes: - ./jrebel.jar:/jrebel.jar - ./lib/libjrebel64.so:/lib/libjrebel64.so environment: - JAVA_OPTS=-agentpath:/lib/libjrebel64.so -Drebel.remoting_plugin=true -Drebel.log.file=/jrebel.log
Save your
docker-compose.yml.Restart your Docker Compose app. Run:
$ docker-compose down $ docker-compose up
To use remote server functionality, add your Docker server address to your IDE workspace for synchronization. Please refer to this page for more information.
Running into an issue?¶
Refer to this page for the first aid of JRebel and here for the understanding of JRebel Logs.
To access the logs located in the Docker container perform the following steps. Find your container ID:
$ docker ps
This will provide a list of the Docker Containers located on the machine. From that list copy the Docker Container ID of the container in question.
$ docker cp [Container ID]:/jrebel.log /path/on/host/machine/jrebel.log
The log will be located in the /path/on/host/machine directory on the host machine.