JRebel with 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.

  1. The Docker container needs to include the JRebel Agent and its platform-specific library. You can download the newest JRebel here.

  2. You need to enable JRebel for the application server in Docker. Add -agentpath:/[JRebel library] and -Drebel.remoting_plugin=true to 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.dll

    Windows 32-bit JDK

    -agentpath:[c:\path\to]jrebel32.dll

    Mac OS X 64-bit JDK

    -agentpath:[path/to]libjrebel64.dylib

    Mac OS X 32-bit JDK

    -agentpath:[path/to]libjrebel32.dylib

    Linux 64-bit JDK

    -agentpath:[path/to]libjrebel64.so

    Linux 32-bit JDK

    -agentpath:[path/to]libjrebel32.so

  3. The 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)

  1. Download the JRebel archive.

  2. Extract jrebel.jar and the lib folder from the root of the downloaded archive. Copy these files to the folder that you will use to generate the image.

  3. Create a new Dockerfile in 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"
  1. Save your Dockerfile.

  2. Build your Docker image.

$ docker build -t [desired image title] .
  1. 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)

  1. Download the JRebel archive.

  2. Extract jrebel.jar and the lib folder from the root of the downloaded archive. Copy these files to the folder that you will use to generate the container.

  3. Create a new docker-compose.yml or add to an existing docker-compose.yml the 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
  1. Save your docker-compose.yml.

  2. 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?

  1. Refer to this page for the first aid of JRebel and here for the understanding of JRebel Logs.

  2. 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.