The idea / motivation

In order to run VisualVM from predefined configuration you need to point the app to the user directory. This directory takes about 20MB, but 90% of the the content is actually generated or repeated.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
➜  4devops-visualvm git:(master) du -sh tw-sl/*
244K    tw-sl/config
7.3M    tw-sl/modules
 52K    tw-sl/repository
4.0K    tw-sl/update
104K    tw-sl/update_tracking
 11M    tw-sl/var

➜  4devops-visualvm git:(master) du -sh tw-wool/*
248K    tw-wool/config
7.2M    tw-wool/modules
 60K    tw-wool/repository
4.0K    tw-wool/update
104K    tw-wool/update_tracking
 11M    tw-wool/var

➜  4devops-visualvm git:(master) du -sh tw-wool
 19M    tw-wool

The only part that is specific and worthy of maintaining in the Git repo is repository

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
➜  4devops-visualvm git:(master) du -sh tw-wool/repository/*
 16K    tw-wool/repository/hosts
 44K    tw-wool/repository/jmxapplications
 
➜  4devops-visualvm git:(master) tree tw-wool/repository
tw-wool/repository
├── hosts
│   ├── 10.206.8.130.properties
│   ├── 10.206.8.131.properties
│   ├── 10.206.8.134.properties
│   └── 10.206.8.35.properties
└── jmxapplications
    ├── 1445526765721.jmx
    │   └── jmxapplication.properties
    ├── 1445526765722.jmx
    │   └── jmxapplication.properties
    ├── 1445526765723.jmx
    │   └── jmxapplication.properties
    ├── 1445526765724.jmx
    │   └── jmxapplication.properties
    ├── 1445526765725.jmx
    │   └── jmxapplication.properties
    ├── 1445526765726.jmx
    │   └── jmxapplication.properties
    ├── 1445526765727.jmx
    │   └── jmxapplication.properties
    ├── 1445526765728.jmx
    │   └── jmxapplication.properties
    ├── 1445526765729.jmx
    │   └── jmxapplication.properties
    ├── 1445526765730.jmx
    │   └── jmxapplication.properties
    └── 1445526765731.jmx
        └── jmxapplication.properties
 
13 directories, 15 files

which contains the hosts and JMX app definitions

Ideally, we would want to have Docker container that would encapsulate the VisualVM install and provide as external volume only the configuration part. This part is small enough (and textual) so that it can be maintained efficiently in Git while the common and generated files(rest of the 20MB) will be inside container

Quick and dirty solution

For this to work, we need Docker container capable of running GUI application and efficient client access (e.g. VNC)

Starting point is https://github.com/ConSol/docker-headless-vnc-container

I have tested the container and selected xfce+ubuntu for start

1
2
3
4
5
6
7
➜  ~ docker run -d -p 5901:5901 -p 6901:6901 -e VNC_RESOLUTION=800x600 consol/ubuntu-icewm-vnc
 
➜  ~ docker run -d -p 5901:5901 -p 6901:6901 consol/centos-xfce-vnc
 
Connect with JollyFastVNCPro - port 5901 / vncpassword
or
http://localhost:6901/

I have installed inside this container visualVM, ssh client using docker exec and made commit (actually, 3 commits).

The result is available at thinkwrap/ubuntu-xfce-vnc-visualvm:v3 (private image)

How to use it

Create local directory for the shared information containing only hosts and JMX property files. Here is mine

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
➜  test-config tree sim-prod
sim-prod
└── repository
    ├── hosts
    │   ├── 10.200.137.34.properties
    │   ├── 10.200.137.50.properties
    │   ├── 10.200.137.51.properties
    │   ├── 10.200.137.52.properties
    │   └── 10.200.137.53.properties
    └── jmxapplications
 
3 directories, 5 files
 
➜  test-config ll
total 32
-rw-r--r--@ 1 miro  staff    16K 19 Nov 20:43 hosts-file
drwxr-xr-x  3 miro  staff    96B 19 Nov 20:35 sim-prod

Also, copy the /etc/hosts file as hosts-file so that Docker uses your known mappings

Start container with desired resolution and 2 volumes - one for mapped config and one for hostfile

1
2
test-config docker run -d -p 5901:5901 -p 6901:6901 -e VNC_RESOLUTION=800x600 -v /Users/miro/src/DEVOPS/test-config/sim-prod/repository:/headless/.visualvm/1.3.8/repository -v /Users/miro/src/DEVOPS/test-config/hosts-file:/etc/hosts thinkwrap/ubuntu-xfce-vnc-visualvm:v3
e12adcb030a5706f246253ccc93823920a0494b5ae962eb54b8ce2b9627bdbc4

Connect via Web or via VNC client (use vncpassword as vnc password). Degree of uglyness will depend on the client used. The URL to connect to is localhost:5901.

On Mac, you can use OOTB Share Screen app with URL vnc://localhost:5901

Start VisualVM using shortcut - note that provided config is loaded