Running Fiji in headless mode inside docker container

Hi guys,

I created a docker container with an up-to-date Fiji and wrote python script than runs fine in headless mode locally on my machine.
When I now run the docker image Fiji starts in headless mode and the “Welcome ImageJ2 & Co” text shows up as html-like text inside the console. And this prevents my script from being executed.

The current workaround is to start Fiji inside the docker in headless mode once without calling the script and wait a while. And then start the Fiji in headless mode again now calling the script. The 2nd time the “Welcome” stuff will not show up any more and the script runs as expected.

This is a bit strange, but I have no idea, how to prevent that. Is there a way to supress that “Welcome” stuff from blocking my script?

As far as I can tell, the Welcome message is displayed by DefaultWelcomeService here:

As the javadoc comment says, it is intended to be displayed only when a user interface is actually shown for the first time. The issue might be that when running headless, the “UI” that is “shown” is the HeadlessUI :slight_smile:. So I guess the fix should be to teach the WelcomeService to not display anything when the UI name is "headless"

Would you care to create an issue in the scijava-common repository?

I would suggest the following fix:

  1. Add a UIService parameter to DefaultWelcomeService.
  2. Return immediately in the onEvent(UIShownEvent) if uiService.isHeadless().
2 Likes

I made the changes as suggested:

https://github.com/scijava/scijava-common/pull/304

@sebi06 could you please test if replacing scijava-common-2.64.0.jar in your Fiji installation by this jar file fixes things for you?

3 Likes

I will try as soon as I am back to my office next week.
Thanks for your help.

Hi,

I just wnated to test the jar, but the link is not working anymore. I read https://github.com/scijava/scijava-common/pull/304 and does that mean the problem is fixed now?

If yes, I just need to build a new container with the latest Fiji, correct?

It should be fixed, but I didn’t have a chance to test it in the way you’re using it.

No, the latest scijava-common build was not yet uploaded to the update site serving the latest Fiji.

For now you should test by replacing scijava-common-2.64.0.jar in your Fiji installation by scijava-common-2.66.2-SNAPSHOT.jar from here: http://maven.imagej.net/service/local/repositories/snapshots/content/org/scijava/scijava-common/2.66.2-SNAPSHOT/scijava-common-2.66.2-20171031.172306-4.jar

1 Like

Hi guys,

i tested the scijava-common-2.66.2-20171031.172306-4.jar, did build a new docker image and run the workflow. And it works. The welcome message is not showing up anymore. Perfect!

Thanks a lot,

Sebi

λ docker run -e "WFE_INPUT_JSON={ ... }" -v C:\Temp\input:/input -v C:\Temp\output:/output fiji_headless
Java HotSpot(TM) 64-Bit Server VM warning: ignoring option PermSize=128m; support was removed in 8.0
Java HotSpot(TM) 64-Bit Server VM warning: Using incremental CMS is deprecated and will likely be removed in a future release
Nov 08, 2017 10:38:33 AM java.util.prefs.FileSystemPreferences$1 run
INFO: Created user preferences directory.
[Wed Nov 08 10:38:37 UTC 2017] [INFO] [] Script Directory: /Fiji.app/scripts
[Wed Nov 08 10:38:40 UTC 2017] [INFO] [] Test
[Wed Nov 08 10:38:40 UTC 2017] [INFO] [] Filename                      : /input/CA_GuidedAcq_BrainSlides.czi
[Wed Nov 08 10:38:40 UTC 2017] [INFO] [] BinFactor                     : 4
[Wed Nov 08 10:38:40 UTC 2017] [INFO] [] Filter Radius                 : 5
[Wed Nov 08 10:38:40 UTC 2017] [INFO] [] Min. Partice Size             : 1000
[Wed Nov 08 10:38:40 UTC 2017] [INFO] [] Min. Circularity              : 0.01
[Wed Nov 08 10:38:40 UTC 2017] [INFO] [] Max. Circularity              : 0.99
[Wed Nov 08 10:38:40 UTC 2017] [INFO] [] Threshold Method              : Triangle
[Wed Nov 08 10:38:40 UTC 2017] [INFO] [] Threshold Background          : black
[Wed Nov 08 10:38:40 UTC 2017] [INFO] [] Headless Mode                 : True
[Wed Nov 08 10:38:40 UTC 2017] [INFO] [] Add Particles to ROI-Manger   : False
[Wed Nov 08 10:38:40 UTC 2017] [INFO] [] Save Particles as Image       : True
[Wed Nov 08 10:38:40 UTC 2017] [INFO] [] Save Format                   : png
[Wed Nov 08 10:38:40 UTC 2017] [INFO] [] Save Results                  : True
[Wed Nov 08 10:38:40 UTC 2017] [INFO] [] ------  START IMAGE ANALYSIS ------
[WARN] Unknown IlluminationType value 'Fluorescence' will be stored as "Other"
[WARN] Unknown Binning value '5x5' will be stored as "Other"
[WARN] Unknown Binning value '5x5' will be stored as "Other"
[WARN] Unknown Binning value '5x5' will be stored as "Other"
[WARN] Unknown Binning value '5x5' will be stored as "Other"
[WARN] Unknown IlluminationType value 'Fluorescence' will be stored as "Other"
[WARN] Unknown Binning value '5x5' will be stored as "Other"
[WARN] Unknown Binning value '5x5' will be stored as "Other"
[WARN] Unknown Binning value '5x5' will be stored as "Other"
[WARN] Unknown Binning value '5x5' will be stored as "Other"
[Wed Nov 08 10:38:43 UTC 2017] [INFO] [] Opening Image ...
[Wed Nov 08 10:38:43 UTC 2017] [INFO] [] File Extension   : .czi
[Wed Nov 08 10:38:43 UTC 2017] [INFO] [] Resolution Count : 1
[Wed Nov 08 10:38:43 UTC 2017] [INFO] [] SeriesCount      : 4
[Wed Nov 08 10:38:43 UTC 2017] [INFO] [] Getting Image Series : 0
[Wed Nov 08 10:38:43 UTC 2017] [INFO] [] Start Processing ...
[Wed Nov 08 10:38:43 UTC 2017] [INFO] [] Apply Binning ...
[Wed Nov 08 10:38:43 UTC 2017] [INFO] [] Apply Filter ...
[Wed Nov 08 10:38:44 UTC 2017] [INFO] [] Convert to 8-bit ...
[Wed Nov 08 10:38:44 UTC 2017] [INFO] [] Apply Threshold ...
        Label   Area    BX      BY      Width   Height  Slice
1       CA_GuidedAcq_BrainSlides.czi - CA_GuidedAcq_BrainSlides.czi #1  6371376.250     8811.019        504.287 3151.795        2787.588        1
2       CA_GuidedAcq_BrainSlides.czi - CA_GuidedAcq_BrainSlides.czi #1  6077825.930     1793.021        546.311 3193.819        2563.460        1
3       CA_GuidedAcq_BrainSlides.czi - CA_GuidedAcq_BrainSlides.czi #1  6299754.681     9133.202        8951.099        3221.835        2647.508        1
4       CA_GuidedAcq_BrainSlides.czi - CA_GuidedAcq_BrainSlides.czi #1  5384175.944     714.407 9861.617        2927.668        2479.412        1
[Wed Nov 08 10:38:44 UTC 2017] [INFO] [] Saving Processed Image to : /output/CA_GuidedAcq_BrainSlides_PA.png
[Wed Nov 08 10:38:44 UTC 2017] [INFO] [] FileCheck Result : True
[Wed Nov 08 10:38:44 UTC 2017] [INFO] [] Saved Results to : /output/CA_GuidedAcq_BrainSlides_RESULTS.txt
[Wed Nov 08 10:38:44 UTC 2017] [INFO] [] Updated Metadata and writing JSON to: /output/Metadata.json
[Wed Nov 08 10:38:44 UTC 2017] [INFO] [] Done.
1 Like