Ah! FreeSurfer 5.3.0 is the reason. I think the license file format has changed at some point. I'm not sure how to get a 5.3.0 license file. Perhaps someone else on the list knows?
-Paul
________________________________________ From: Óscar Peña-Nogales opennog@gmail.com Sent: Friday, October 10, 2025 10:42 AM To: Freesurfer support list Subject: [Freesurfer] Re: recon-all fails with "Invalid FreeSurfer license key" when executed via Docker SDK but works interactively
External Email - Use Caution
Hello,
Thanks for your inputs, however, when inspecting the container environment in runtime I can see that the variables are properly set: 'FREESURFER_HOME': '/usr/local/freesurfer', 'FS_LICENSE': '/usr/local/freesurfer/license.txt', 'FREESURFER_SETUP': '/usr/local/freesurfer/SetUpFreeSurfer.sh', 'MINC_BIN_DIR': '/usr/local/freesurfer/mni/bin',
But I get this error when running right after the command recon-all
-------------------------------------------------------------------------- ERROR: Invalid FreeSurfer license key found in license file /usr/local/freesurfer/license.txt If you are outside the NMR-Martinos Center, go to http://surfer.nmr.mgh.harvard.eduhttp://secure-web.cisco.com/1UuxJ9PKT3fFdW0wXrNTOPTIiSy5-20crKGYhylPKuP_0IgqhwoqokkI1giaJcCCvXswT9R98XVpU5kaE4xZLZLPahxmDusPhPIfpID8vQY7yCkpJ2EXhJThdlfgh42RD-WKODDM4fyt4mu6XRiMd_1ZMPOxrWhTWuSmY6pT5wTKR8-Wa6MrzsAyRt57D9td0I4ibyaIEUyJCd2Y92PJB37VztMaPvyRB0eoW3zVlu0pV0A-9cjdBF1KWHmnPVqwbldIKEeaNQjr7JIA9tVd4tOVOOxKf5uAWH-1BA0PkEO2i3ug9nLPQ4_QNcUhCKWWh/http%3A%2F%2Fsurfer.nmr.mgh.harvard.edu to get a valid license file (it's free). If you are inside the NMR-Martinos Center, make sure to source the standard environment. --------------------------------------------------------------------------
Then I don't think the SDK is modifying the environment, also the license.txt is found in the default location. I can even read it and print it at runtime. This is only happening for FreeSurfer 5.3.0 but not for later FreeSurfer versions (which are built using the same steps).
Any other suggestions?
Óscar
On Thu, 9 Oct 2025 at 14:33, Wighton, Paul <PWIGHTON@mgh.harvard.edumailto:PWIGHTON@mgh.harvard.edu> wrote: Hi Oscar,
My guess is the FREESURFER_HOME environment variable is being cleared by the SDK. FreeSurfer will by default look for the license file at $FREESURFER_HOME/license.txt.
There is also the environment variable FS_LICENSE which can tell freesurfer where the license file is, but since in your case the file is in the standard location, I'm guessing that is not being used.
So setting FREESURFER_HOME=/usr/local/freesurfer
or FS_LICENSE=/usr/local/freesurfer/license.txt
should work.
-Paul
________________________________________ From: Óscar Peña-Nogales <opennog@gmail.commailto:opennog@gmail.com> Sent: Wednesday, October 8, 2025 5:04 AM To: Freesurfer support list Subject: [Freesurfer] recon-all fails with "Invalid FreeSurfer license key" when executed via Docker SDK but works interactively
External Email - Use Caution
Hi all,
I’m running recon-all inside a Docker container, but it fails with the following error when launched programmatically through an SDK:
ERROR: Invalid FreeSurfer license key found in license file /usr/local/freesurfer/license.txt If you are outside the NMR-Martinos Center, go to http://surfer.nmr.mgh.harvard.eduhttp://secure-web.cisco.com/1UuxJ9PKT3fFdW0wXrNTOPTIiSy5-20crKGYhylPKuP_0IgqhwoqokkI1giaJcCCvXswT9R98XVpU5kaE4xZLZLPahxmDusPhPIfpID8vQY7yCkpJ2EXhJThdlfgh42RD-WKODDM4fyt4mu6XRiMd_1ZMPOxrWhTWuSmY6pT5wTKR8-Wa6MrzsAyRt57D9td0I4ibyaIEUyJCd2Y92PJB37VztMaPvyRB0eoW3zVlu0pV0A-9cjdBF1KWHmnPVqwbldIKEeaNQjr7JIA9tVd4tOVOOxKf5uAWH-1BA0PkEO2i3ug9nLPQ4_QNcUhCKWWh/http%3A%2F%2Fsurfer.nmr.mgh.harvard.eduhttp://secure-web.cisco.com/1caZqJPIIzERnX6myZfn7lHvJljbS0zsXzR6nmSo47CLhLQRG9rdbkiIwrMAAX_nB5vbgB1SinG3-ZgBHMj5v1kXw9Kzv2wjW822yvRSfacJPLxUclBW_SVfJmKMsRZJUYpRlyHv2tHipdp2sGkfU_uvsWOgij6a3Af0GFnxxy-lh717ouUQHFkQdxjpHzUyK8MdoIyl3TUT7JnwDVxDoS5a3YHcLkk3k9qOctUUpb3xhz22OxgPO5rn-Dyva9oEBOcajMvvJJ4C0-P1zH5ObSHsHQPDs46JbKWyOyBJb9waFQxxvzMy1_5J_Y3Qf2w2F5Iwy4jqW_0imkQOzvVAbCQ/http%3A%2F%2Fsurfer.nmr.mgh.harvard.edu to get a valid license file (it's free). If you are inside the NMR-Martinos Center, make sure to source the standard environment.
The command used by the SDK looks like this: docker run -v /usr/local/lib/python3.10/dist-packages/xxxx/execution/communication.patch:/usr/local/lib/python3.11/dist-packages/xxxx/sdk/communication.py:ro \ --cap-drop=NET_RAW -dt --name analysis_1420668 --entrypoint /bin/bash \ --cpus=4 --memory=16384m \ europe-west3-docker.pkg.dev/xxxx/freesurfer_530:dev-1.0http://secure-web.cisco.com/10bra9HdhlTj-ut3zc8LkwW4v3HqCNE8wUuAPOxTCAvs-W1p5grvzxThkrG5888fg9txOOvbsWIeO118FIB4tJNtU82IWP3Tw9MfX8A_2hOIBofMORtaRHjIRA76ZhdWDhsAMdufHkbhc41hb2bs5lROt5vdJ3VS2R0eov10hPtJUgqlS36SrvCqsqgMkTHGLfD8X-DYr845SVRUbkjOC3vnOlYzjXJcJZb-UlEDcJ0a_nRqN0oKXpEBaVwjCgRQXE0TK5Lux56YLpjl-JdPZtMQ5U-eo3Xm-iN4UoKGkVNr-xKTA01k0g9b5Ju_S79NG/http%3A%2F%2Feurope-west3-docker.pkg.dev%2Fxxxx%2Ffreesurfer_530%3Adev-1.0http://secure-web.cisco.com/1mwCEJkYKnfdfA22FPsDgHeg-XoCzA3_JkIyAVUiiiBYW-fxkpXwzJWcNA8mMiVFPMO_i08dRg5P8z2TJHyAgLNDI1bsYea4B8_tGf6AdM32EJixbXGcbGSeU45sh_WdYxn9IxNgQuEsRP8bD8e3C8dT7E3RUqyiBmH669XuUk3tkPdNXBnjryIfiipNNwL0ngSj-W0uPCKNe0yoJZ7Fcbuw2HXT3fMXAnlRjFePwpEtWquqGaPBD90e2d7LPU_qVJWtCRDGXAIQO-qVPgbzfkC9yNWEeXAgOeddwdgNHfErpiUIvw1rRxogfxBPUCF0FWYIsfzklPzKELpkzdqxMbw/http%3A%2F%2Feurope-west3-docker.pkg.dev%2Fxxxx%2Ffreesurfer_530%3Adev-1.0 \ /xxxx/entrypoint.sh --project 2289 --analysis 1420668 \ --token xxxx --url https://xxxxx.com/https://secure-web.cisco.com/1dwNyPHyZdF74N8CBbePYmDs_N5_8E-GU4rmVapLMhkXkNSf7f6pcnvxYQSKptKiCTyzoyGBG0gS6JD6rR9HqSzCYiBGf-cCCit7BG2iclr4tX-vIB920riAckJmrhacfFdB3PQ29DNXZ2gQ4Kts3gRejqTgCZd4QG-BHlAPuZgRSpPATVrAizqas2mf88nEmFAk1VHfYkmTgUxICNCjOn5sRwIhvBJF23ToXf3WukOJoJw-BtlueshU_reGsQ7QcFp0I4ycQRdluhZe_7k_0Wb_XJlVHezuxM1t4T8WaNIKQNQ6oGNLZhbu3ej_dW_b-/https%3A%2F%2Fxxxxx.com%2Fhttps://secure-web.cisco.com/1_ZG55biN3BILRStBLxIfao5TAMons8aRRsmdYirMJ90OwD2Lt1Q4r73hfoxAjuZKYF9WuMsDeJHZjd_EegU9PPSWTRd_-snZtEdbl-L6SrLp8leodWB8PW8uIx_2TgeZ_GzwXKw5tvLFZrlW4lfOyr-KMho7jyCobO0U0VKbcTHZU5_pQO6_l0PvazBy2vN5XI8rLwL-orl0PRuSn_hkxRUaWodXDQ9d8laPt802auFpG0h2Tqz-OvDpcRy4lOB7613atQgzO3Ud4rgjY7IkDwJnyeNCO9R9u_xT_9p9SqwzZqnhTkZl6WXtWCR-N4Y3I5Um1eIpEOuERQNut2spww/https%3A%2F%2Fxxxxx.com%2F \ --tool-path tool:run
However, when I start the container manually (e.g., docker run -it ... /bin/bash) and run recon-all inside it directly, the license is detected and validated correctly. So the license.txt file at /usr/local/freesurfer/license.txt itself appears to be valid. This suggests the issue is related to how the container is executed by the SDK or entrypoint, possibly involving the entrypoint script /xxx/entrypoint.sh altering the environment before recon-all starts.
The Docker container has: Ubuntu 22.04 Python 3.11
Has anyone seen a similar issue where FreeSurfer fails to validate the license only when invoked non-interactively?
Are there specific environment variables or checks that recon-all performs which might differ when running under /bin/bash -c or through an SDK wrapper?
Any insights or debugging suggestions would be greatly appreciated.
Thanks! _______________________________________________ Freesurfer mailing list -- freesurfer@nmr.mgh.harvard.edumailto:freesurfer@nmr.mgh.harvard.edu To unsubscribe send an email to freesurfer-leave@nmr.mgh.harvard.edumailto:freesurfer-leave@nmr.mgh.harvard.edu https://mail.nmr.mgh.harvard.edu/mailman3/lists/freesurfer@nmr.mgh.harvard.e...https://secure-web.cisco.com/1azVNbHYfrpkN0ViChl6dOJcXJLtuSXYazp3wjXvAQIekhxhdi4fSKjDQlYfk5oF1Oi8fN7JeXZMC7Teol66gLKf2KL9qSYKzYP_ouWXDKmC4a8Du_kgeeXTwh-GEpnyyffHT4jjrRt_hOMkpM74lbVs8yENnOdlp8yAsiBvnjYCzfO73OQP1UMT8sYXCjeN1V-9pAkmGuruztnStFmxUT2-XTZQraJ-4aT45zNHnEx825h7YUrX2HP_jFmJQPkICuJOvSmq8_4kvRAYtadhvJ8tcEgPJdWlcq-YDyF23qdGoyZQkzuGpi1k2V79il616/https%3A%2F%2Fmail.nmr.mgh.harvard.edu%2Fmailman3%2Flists%2Ffreesurfer%40nmr.mgh.harvard.edu%2F The information in this e-mail is intended only for the person to whom it is addressed. If you believe this e-mail was sent to you in error and the e-mail contains patient information, please contact the Mass General Brigham Compliance HelpLine at https://www.massgeneralbrigham.org/compliancelinehttps://secure-web.cisco.com/1mRJFOoGXgrrIRSmKfaRCNPfFodvN1HTrg_NnlvaIiJSkM2N_bUX16WLALNzpiwZEVmyyEx3ST_wqX3z7cT2GHnCGI-cTgWhbmzVBcbKfa1jJHwj3anL1c1tu0GVQRCtATH8-N-kf9ljQjPgzkv7hDUVtBZ0tacxVFZ2mA2AITK4Wnt3NzdvxPaGCOtotoEPgGSF8C0syhZvCWA0WeI1d7te5Tm4UB3scQcB_OVH74BRxq_8Y7m6s9ihZbwevCp9vddcSpBgZMAKdKHjn2mN0wW5pEBHcH4fnHGJP0Qq5XZLZnN2_6uO-7qxgLjY-HTg1/https%3A%2F%2Fwww.massgeneralbrigham.org%2Fcomplianceline <https://www.massgeneralbrigham.org/compliancelinehttps://secure-web.cisco.com/1mRJFOoGXgrrIRSmKfaRCNPfFodvN1HTrg_NnlvaIiJSkM2N_bUX16WLALNzpiwZEVmyyEx3ST_wqX3z7cT2GHnCGI-cTgWhbmzVBcbKfa1jJHwj3anL1c1tu0GVQRCtATH8-N-kf9ljQjPgzkv7hDUVtBZ0tacxVFZ2mA2AITK4Wnt3NzdvxPaGCOtotoEPgGSF8C0syhZvCWA0WeI1d7te5Tm4UB3scQcB_OVH74BRxq_8Y7m6s9ihZbwevCp9vddcSpBgZMAKdKHjn2mN0wW5pEBHcH4fnHGJP0Qq5XZLZnN2_6uO-7qxgLjY-HTg1/https%3A%2F%2Fwww.massgeneralbrigham.org%2Fcomplianceline> .