allBlogsList

Sitecore on Docker Part 2

Fixing Sitecore Startup Problems

In my previous blog post, Sitecore 9.3.0 on Docker Part 1 – Hosting Docker on an External Drive, I mentioned that upon starting my Sitecore 9.3.0 test container I had a few startup problems:

1.    The xconnect-automationengine service cannot find its Sitecore license and fails

2.    The xconnect-indexworker service cannot find its Sitecore license and fails as well

To my chagrin, I find most of these problems are addressed in the .\docker-images\build\windows\tests\9.3x\README.md file:

Running XC

Prerequisites and considerations

·        XC uses the old 9.2 AND new 9.3 license mechanism, so set the LICENSE_PATH AND SITECORE_LICENSE environment variables.

·        XC requires DNS names to be configured on your host. To do so automatically you can use [whales-names](https://github.com/gregolsky/whales-names "https://github.com/gregolsky/whales-names"). Otherwise, you will need to configure it manually: add identity and bizfx DNS names your hosts file - please note that it needs to reference the internal Container IP, not your local host IP (127.0.0.1).

·        Ensure that your local XC instance is not running, specifically BizFx on port 4200 - bizfx container will run on the same local port. It is recommended to stop local IIS completely.

...

Getting into it

1. XC uses the old 9.2 AND new 9.3 license mechanisms. We find most of the details on how to fix this in the .\docker-images\build\INSTRUCTIONS.md file, in the “For Sitecore 9.3.x” section.

The TLDR; is as follows:

  1. Modify the .\docker-images\build\Set-LicenseEnvironmentVariable.ps1 file
    I added code to persist the Sitecore license path to the Windows Environment variables. My additions are bolded and italicized:

    # persist in current session
    		$env:SITECORE_LICENSE = $licenseString
    		
    
  2. Modify the xconnect-automationengine service definition in the docker-compose.xc.sxa.storefront.yml file
    There’s two modifications you’ll need to make:

    1. Add an environment variable, SITECORE_LICENSE_LOCATION. The value of this variable is the location within the Docker image where the Sitecore license is to be found.

      ...
      environment:
      	SITECORE_LICENSE_LOCATION: C:\worker\App_Data\jobs\continuous\AutomationEngine\App_Data
      ...
      				
      
    2. Add a new mounted volume: The following volume definition mounts the LICENSE_PATH environment variable’s value to the location within the Docker image where the Sitecore license is found.

      ...
      volumes:
      	- ${LICENSE_PATH}:C:\worker\App_Data\jobs\continuous\AutomationEngine\App_Data
      ...
      				
      
  3. Modify the xconnect-indexworker service definition in the docker-compose.xc.sxa.storefront.yml file
    We’ll need to make the same two modifications we made to the xconnect-automationengine service, but with a change in path:

    1. Add an environment variable, SITECORE_LICENSE_LOCATION. The value of this variable is the location within the Docker image where the Sitecore license is to be found.

      ...
      environment: 
      	SITECORE_LICENSE_LOCATION: C:\worker\App_Data\jobs\continuous\IndexWorker\App_Data
      ...
      	
      
    2. Add a new mounted volume: The following volume definition mounts the LICENSE_PATH environment variable’s value to the location within the Docker image where the Sitecore license is found.

      ...
      volumes:
      	- ${LICENSE_PATH}:C:\worker\App_Data\jobs\continuous\IndexWorker\App_Data
      ...
      				
      

2. SXC requires DNS names to be configured on your host. There are a couple of ways we can address this:

  1. whales-names. This is a great solution, but it’s a script that needs to be run after each startup

  2. Rob Ahnemann’s Monitor. This solution is used by the Sitecore Horizon image as mentioned in the .\docker-images\build\windows\tests\9.3x\README.md file.

I decided to work using Monitor, because of its ease of use. Simply take the monitor service definition from the  .\docker-images\build\windows\tests\9.3.x\docker-compose.xp.sh.yml file, and copy it into the docker-compose.xc.sxa.storefront.yml file. After starting your Docker container, you may now view your hosts file to see your Docker-hosted domains written to it.

3. Ensure that your local SXC instance(s) are not running. If your local BizFx instance is using the default port of 4200, the Docker-hosted instance of BizFx will conflict. Sitecore suggests turning off the World Wide Web Publishing Service.

I find that modifying the default ports on which I install Sitecore Commerce services to be helpful, that way I can have several versions running locally.

Our Second Attempt

  1. Run our modified .\docker-images\build\Set-LicenseEnvironmentVariable.ps1 script:

    >Set-LicenseEnvironmentVariable.ps1 D:\Git\license.xml -PersistForCurrentUser
    
    
  2. Close our terminal and open a new one, to assure our new LICENSE_PATH has been written.

    >Get-Item Env:LICENSE_PATH
    >Name                           Value
    ----                           -----
    LICENSE_PATH                   D:\Git
    
    
  3. Run the Clean script in our tests directory:

    .\docker-images\build\windows\tests\9.3.x\Clean-Data.ps1
    
  4. Run our modified docker compose definition .\docker-images\build\windows\tests\9.3.x\docker-compose.xc.sxa.storefront.yml:

    >docker-compose -f .\docker-compose.xc.sxa.storefront.yml
    
    

And, eventually, our Docker 93x Container comes up.