Search Unity

Batch mode license activation fails in a Docker container

Discussion in 'Windows' started by tgwozdz_unity, Sep 20, 2019.

  1. tgwozdz_unity

    tgwozdz_unity

    Joined:
    Aug 6, 2019
    Posts:
    8
    Hello!

    I'm trying to set up a Windows Docker container to perform our automated Unity builds. I'm trying to activate the license and I'm getting an error.

    I'm running the following command in the Docker container (in a powershell console).

    Start-Process -FilePath 'c:\program files\unity\editor\unity.exe' -ArgumentList '-batchmode','-quit','-nographics','-logfile','log.txt','-serial','xxx','-username','yyy','-password','zzz' -Wait


    The log then gets the following output:

    BatchMode: Unity has not been activated with a valid License. Could be a new activation or renewal...

    (Filename: C:\buildslave\unity\build\Platforms/Windows/Modules/LicensingLegacy/WinILicensingAdapter.cpp Line: 43)

    DisplayProgressbar: Unity license
    Cancelling DisplayDialog: Updating license failed Failed to update license within 60 seconds. Exiting.
    This should not be called in batch mode.

    (Filename: C:\buildslave\unity\build\Editor/Platform/Windows/EditorUtility.cpp Line: 1162)

    Exiting without the bug reporter. Application will terminate with return code 1


    It seems like Unity might be trying to display some kind of dialog box, but is unable to because it's in a headless container? Is there some way around this? When I run the same command outside of the Docker container, it completes successfully.
     
    nguetter, GuillaumeCL and spauley like this.
  2. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,680
    Hey I just heard back from our license team folks. They had these suggestions:

    That means login failed.
    1. Check username and password
    2. Clear Editor cache (C:\Users\<username>\AppData\LocalLow\Unity\Browser\ or ~/Library/Unity/Browser) * ~ means user’s folder in mac system.
    3. Try to activate it again

    Let me know if this helps if we need to do further troubleshooting.
     
  3. tgwozdz_unity

    tgwozdz_unity

    Joined:
    Aug 6, 2019
    Posts:
    8
    The username, password and serial number are correct. I am able to run the same command outside of the Docker container successfully.

    The cache is empty within the Docker container, the container contains a clean install of Unity, however the activation still fails with the same error.

    Is there anything else that could be causing this?
     
  4. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,680
    Which version of Unity are you on? There was a known issue in Unity 2018.1 and 2018.2 that would cause "Cancelling DisplayDialog: Updating license failed Failed to update license within 60 seconds. Exiting.". It was fixed late in 2018.2 cycle.
     
  5. tgwozdz_unity

    tgwozdz_unity

    Joined:
    Aug 6, 2019
    Posts:
    8
    I tried this with both 2019.1.14 and 2018.2.21 with the same results for both.
     
  6. matissehack

    matissehack

    Joined:
    Oct 5, 2019
    Posts:
    2
    I just ran into this exact issue as well.

    I have a Windows container based on mcr.microsoft.com/windows:1903 and I'm trying to activate a fresh install of Unity version 2018.4.2f1 on it. I also tried Unity version 2019.2.8f1 without any luck.

    The command works fine outside the container.
     
  7. Amir_AZNK

    Amir_AZNK

    Unity Technologies

    Joined:
    Jul 9, 2019
    Posts:
    15
    Hi guys,

    I reproduced the same issue on my side. What I did was disabled all network adaptors on my machine and run the activate license command and I got the same logs.

    I suspect that Unity within the container cannot talk to Unity's licensing backend. Try to check connection and let us know.
     
  8. tgwozdz_unity

    tgwozdz_unity

    Joined:
    Aug 6, 2019
    Posts:
    8
    My container can talk to the Internet just fine. For instance, I was able to curl unity.com from within the container successfully. I can also confirm this with a Wireshark dump of network traffic from the container. However when running the unity activate command, I saw no traffic being generated at all when it failed, as if it wasn't even trying to talk over the network.

    Is there anything else I can try?
     
  9. Amir_AZNK

    Amir_AZNK

    Unity Technologies

    Joined:
    Jul 9, 2019
    Posts:
    15
    Hi
    Would it be possible to provide full editor logs?

    Also please check if you can talk to license.unity3d.com

    Regards,
    Amir
     
    Last edited: Oct 16, 2019
  10. tgwozdz_unity

    tgwozdz_unity

    Joined:
    Aug 6, 2019
    Posts:
    8
    Which log would that be? Where would I find it? What i pasted in the original comment is the full contents of log.txt that was generated by the command I pasted. Is there a log elsewhere I can look at?
     
  11. Amir_AZNK

    Amir_AZNK

    Unity Technologies

    Joined:
    Jul 9, 2019
    Posts:
    15
    It seems that the is a problem that prevents full logs to be shown.

    Editor logs on windows machine are located at: C:\Users\<your username>\AppData\Local\Unity\Editor\Editor.log

    It seems that if '-nographics' is used, there is no log. Now lets try this scenario. Remove '-nographics' and '-logfile log.txt' arguments and see if new Editor.log file is generated at the specified location.

    For security reasons don't post your Editor.log file here. Direct message please.

    Regards,
     
  12. tgwozdz_unity

    tgwozdz_unity

    Joined:
    Aug 6, 2019
    Posts:
    8
    Running without the parameters you specified produces no console output at all. The Editor.log file you mentioned is exactly the same as the contents I pasted in the original comment.
     
  13. Amir_AZNK

    Amir_AZNK

    Unity Technologies

    Joined:
    Jul 9, 2019
    Posts:
    15
    I am installing 2019.1.14f now to see what do I get.
     
  14. Amir_AZNK

    Amir_AZNK

    Unity Technologies

    Joined:
    Jul 9, 2019
    Posts:
    15
    Alright. I tried with 2019.1.14f and I got exactly the same output as what you got, however only if I disable my network adaptor. In the case that I am connected to internet I have more logs and activation is successful.

    Technically this log is not helping at all.

    This MIGHT be a legacy issue that was hopefully fixed in one of the current Pre-Releases.

    Kindly install Unity 2020.1.0a8 and 2019.3.0b7 (can be downloaded easily through Unity HUB) and run them within the container. Capture the same Editor.log file across different runs. Hopefully we will get more insight as the root cause of this issue after this experiment.

    Regards,
    Amir
     
  15. tgwozdz_unity

    tgwozdz_unity

    Joined:
    Aug 6, 2019
    Posts:
    8
    Hey Amir,

    I tried again with Unity 2020.1.0a8 and here's the log:


    [Licensing::Module] Channel doesn't exist: "LicenseClient-ContainerAdministrator"
    [Licensing::Module] Successfully launched the LicensingClient (PId: 5944)
    [Licensing::Module] Successfully connected to LicensingClient on channel: "LicenseClient-ContainerAdministrator"
    Entitlement-based licensing initiated
    [LicensingClient] Licenses updated successfully
    BatchMode: Unity has not been activated with a valid License. Could be a new activation or renewal...
    (Filename: C:\buildslave\unity\build\Platforms/Windows/Modules/LicensingLegacy/WinILicensingAdapter.cpp Line: 44)

    DisplayProgressbar: Unity license
    [Licensing::Module] Error: License is not active (com.unity.editor.headless). HasEntitlements will fail.
    Cancelling DisplayDialog: Failed to activate/update license Failed to activate license within 60 seconds. Please try aga
    in later or contact support@unity3d.com
    This should not be called in batch mode.
    (Filename: C:\buildslave\unity\build\Editor/Platform/Windows/EditorUtility.cpp Line: 1116)

    Exiting without the bug reporter. Application will terminate with return code 1
     
  16. Amir_AZNK

    Amir_AZNK

    Unity Technologies

    Joined:
    Jul 9, 2019
    Posts:
    15
    I looked at the logs and still now much from there. I have same logs as your logs only when I don't have internet connection.

    Still I am leaning toward having no internet access. To see that yourself try running it on regular Windows machine (or any machine not within container) as you mentioned you had successful experience activating a license file. You will see the amount of details and addresses that Unity is trying to connect. And then try to ping each one of them from the container (i.e. license.unity3d.com).

    Kindly post your experience here so that we can move forward from there.

    Regards
     
  17. tgwozdz_unity

    tgwozdz_unity

    Joined:
    Aug 6, 2019
    Posts:
    8
    Here's the log from Unity 2019.3.0b7


    [LicensingClient] ERROR Failed to connect to local IPC
    [Licensing::Module] Failed to connect to channel: LicenseClient-ContainerAdministrator
    [Licensing::Module] Successfully launched the LicensingClient
    [Licensing::Module] Successfully connected to LicensingClient on channel: LicenseClient-ContainerAdministrator
    [Licensing::Module] Successfully launched and connected to LicensingClient
    Entitlement-based licensing initiated
    [LicensingClient] Licenses Updated successfully in LicensingClient
    BatchMode: Unity has not been activated with a valid License. Could be a new activation or renewal...
    (Filename: C:\buildslave\unity\build\Platforms/Windows/Modules/LicensingLegacy/WinILicensingAdapter.cpp Line: 45)

    DisplayProgressbar: Unity license
    Assertion failed on expression: 'g_BackgroundThread == nullptr'
    (Filename: C:\buildslave\unity\build\Editor/Src/TaskManager.cpp Line: 192)

    [Licensing::Module] License is not active (com.unity.editor.headless). HasEntitlements will fail.
    Cancelling DisplayDialog: Updating license failed Failed to update license within 60 seconds. Exiting.
    This should not be called in batch mode.
    (Filename: C:\buildslave\unity\build\Editor/Platform/Windows/EditorUtility.cpp Line: 1120)

    Exiting without the bug reporter. Application will terminate with return code 1


    I double checked the network connection and I'm indeed able to ping and connect to license.unity3d.com and any other servers that I tried. Networking appears to be working correctly.
     
  18. matissehack

    matissehack

    Joined:
    Oct 5, 2019
    Posts:
    2
    I ran both 2020.1.0a8 and 2019.3.0b7 and got the same output as tgwozdz_unity. The container definitely has a working network connection and I was able to ping license.unity3d.com (it resolved to 35.195.230.199). Happy to try any other troubleshooting steps you can think of!
     
  19. danielo_unity

    danielo_unity

    Unity Technologies

    Joined:
    Apr 12, 2018
    Posts:
    14
    Hi. So within the docker container, we appear to be hitting a network connectivity bug.
    To establish that we indeed have network connectivity, we are calling INetworkListManager::GetConnectivity (similar to what is done here), which appears to be failing.
    We will open a FogBugz to follow this issue, but I'm unsure about the availability of a fix.
     
  20. danielo_unity

    danielo_unity

    Unity Technologies

    Joined:
    Apr 12, 2018
    Posts:
    14
  21. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,680
  22. Nepoxx

    Nepoxx

    Joined:
    Mar 25, 2013
    Posts:
    2
    Why is this issue "Won't fix"? Not being able to active Unity in a docker container is a critical issue. We give your company thousands of dollars to have licenses and the licensing system does not work, how is this not a major issue?
     
  23. etienne_unity

    etienne_unity

    Unity Technologies

    Joined:
    Aug 31, 2017
    Posts:
    102
    Hi @Nepoxx ,

    I re-activated the issue, and we'll look into this if we start to support the Editor in Windows Docker containers.

    Currently, we do not support this (ie: we're not testing releases against this scenario). See this manual page for details. The important bit is:

    Thanks for your understanding.
     
  24. danielo_unity

    danielo_unity

    Unity Technologies

    Joined:
    Apr 12, 2018
    Posts:
    14
    A critical API (to detect internet connectivity) was found to not be working correctly inside the container, so we closed as won't fix. Perhaps we should have said "by-design". ping also did not work for me without a command to the container.

    Investigating further, this API is found to be not working because the netprofm service ("Network List Service") is disabled within the container, either by accident or by design. Re-enabling it is insufficient, as it depends on another service (nlasvc), which must also be re-enabled.
    Furthermore, another critical service is also required, by licensing and perhaps elsewhere: WMI (wmiApSrv).
    I have not investigated beyond this point, but would speculate that there will be other issues (not a huge amount, but some).

    We answered the question (why doesn't licensing work?) at the time, but didn't draw the link to the services which were disabled. Now we know. This is not within our control. It is the docker user's responsibility.

    The Unity Editor is also just a standard Windows application intended for desktop use (with several other satellite processes, that almost always connect to back-end services).
    Docker should be configured such that it does not interfere with its (the Editor's) normal functions (ie. hard dependencies).
    I don't know which part is the users responsibility, vs docker itself, or rather the default settings for Windows images.

    I think the best we could do, is to enumerate the minimum set of dependencies required for use within a standard docker image, but that will take time (especially if we want to support all our major platforms).

    Thanks. Let us know if this helps
     
  25. btristan

    btristan

    Joined:
    Oct 15, 2018
    Posts:
    95
    Listing those dependencies would be awesome. I'm working on the same thing but in Ubuntu. (where 2019.2 and before works but 2019.3 doesn't)
     
  26. Unity2-3drepo

    Unity2-3drepo

    Joined:
    Mar 5, 2019
    Posts:
    2
    seconded, we have this issue, also using ubuntu. We've just updated to 2019.3 and it was working perfectly before in containers.

    I also attempted to allow full access for the container with the following flags, but it didn't resolve it.

    securityContext:
    privileged: true
     
  27. tbensalem

    tbensalem

    Joined:
    Feb 12, 2021
    Posts:
    1
    following on this thread
    https://issuetracker.unity3d.com/issues/cannot-activate-license-within-a-docker-container
    I have tried to activate the license unity on version 2019.4.12f1 and 2020.2.0b9 on a windows docker container "mcr.microsoft.com/windows:2004-amd64" but that failed.
    The command that I've run is as follow:
    Code (CSharp):
    1. Start-Process -FilePath 'C:\PATH_TO_UNITY\\unity.exe' -ArgumentList '-batchmode','-quit','-nographics','-logfile','c:/logs/activate.log','-serial','XXXX','-username','XXXX','-password','XXXX' -Wait
    The logs I got for 2019.4.12f1 are:
    The logs I got for 2020.2.0b9 are:
     
  28. stan_unity969

    stan_unity969

    Joined:
    Sep 30, 2019
    Posts:
    3
    I've managed to get this working for unity 2020.3.14f1

    I had to use mcr.microsoft.com/windows:1909 docker image any later images seems to break it. (have not tested windows server ltsc2022) but 2004 and 20H2 didn't work.

    as mentioned above the issue lies with a couple of windows services not running.

    starting the services when the container boots up is partially the fix I also had to ensure the network was set to private not public and in addition to this I had to setup a docker network using the transparant driver per https://docs.microsoft.com/en-us/virtualization/windowscontainers/container-networking/network-drivers-topologies

    in order to check if the Network List Manager detects if there is internet connection you can run Get-NetConnectionProfile

    Then when building the container I installed a service which runs on bootup to run the powershell script which enables all the services

    Also as a sidenote unity does not seem to run properly with hyperv isolation as such make sure to run the container with --isolation=process The drawback of this is that you need to have the same OS on the container host which means you'll likely have to downgrade windows on your host machine to build 1909.

    Code (CSharp):
    1. Set-Service 'wmiApSrv' -StartupType Automatic
    2. Set-Service 'nlasvc' -StartupType Automatic
    3. Set-Service 'netprofm' -StartupType Automatic
    4. Start-Service 'netprofm'
    5. Start-Service 'wmiApSrv'
    6. Start-Service 'nlasvc'
    7. Set-NetConnectionProfile -Name Network -NetworkCategory Private
    the full docker command I used for running the container is as follows

    Code (CSharp):
    1. docker run -it --isolation=process --device class/5B45201D-F2F2-4F3B-85BB-30FF1F953599 --network=transparent-network test:windows1909
    --device class/5B45201D-F2F2-4F3B-85BB-30FF1F953599 ensures the gpu is accesible to the container which might be handy if you need to do anything with regards to textures etc
     
    riemaeker likes this.
  29. WhaaaatDa

    WhaaaatDa

    Joined:
    Apr 11, 2022
    Posts:
    1
    Not exactly the same issue as OP, but we fixed it in docker by doing a separate command before calling our executeMethod. If we tried to license in the same command as the execute method in 2019.12.5 or later, we got the same error as OP.

    Code (CSharp):
    1. xvfb-run --auto-servernum --server-args='-screen 0 640x480x24' /opt/unity/Editor/Unity -batchmode -nographics -adb2 -logFile $CI_PROJECT_DIR/artifacts/Editor_Build${distributionMethod}.log -username USERNAME@DOMAIN m -password $MY PASS -serial $MY_SERIAL -quit
     
  30. jhughes2112

    jhughes2112

    Joined:
    Nov 20, 2014
    Posts:
    178
    For what it's worth, Unity's network connectivity detection is crap. Even on a native Windows 10, it often fails if you have multiple bridge adapters (because of VMs or other complex configs). In short, you're doing it wrong by relying on a Windows service, since it often picks the wrong adapter to determine connectivity. This is 100% a Unity bug, and there are other forum posts where this has been explained and not fixed for years and years. It's the truth.