After the ninth formatting error in my docker-compose.yml file, I decided to google if you could actually use JSON instead. I heart JSON, for reals.

Whaaaaaaa

Ok, so that’s great news. You can quickly convert your YAML files over to JSON with some online tools. Here’s a good one: https://onlineyamltools.com/convert-yaml-to-json Simply paste your YAML file in there and viola:

{
  "version": "2.4",
  "services": {
    "sql": {
      "image": "${REGISTRY}sitecore-xm-sqldev:${SITECORE_VERSION}-windowsservercore-${WINDOWSSERVERCORE_VERSION}",
      "volumes": [
        ".\\data\\sql:C:\\Data"
      ],
      "mem_limit": "2GB",
      "ports": [
        "44010:1433"
      ],
      "environment": {
        "SA_PASSWORD": "${SQL_SA_PASSWORD}",
        "ACCEPT_EULA": "Y"
      }
    },
    "solr": {
      "image": "${REGISTRY}sitecore-xm-solr:${SITECORE_VERSION}-nanoserver-${NANOSERVER_VERSION}",
      "volumes": [
        ".\\data\\solr:C:\\Data"
      ],
      "mem_limit": "1GB",
      "ports": [
        "44011:8983"
      ],
      "environment": {
        "SOLR_LOG_LEVEL": "INFO"
      }
    },
    "cd": {
      "image": "${REGISTRY}sitecore-xm-cd:${SITECORE_VERSION}-windowsservercore-${WINDOWSSERVERCORE_VERSION}",
      "entrypoint": "powershell.exe -Command \"& C:\\\\tools\\\\entrypoints\\\\iis\\\\Development.ps1\"",
      "ports": [
        "44002:80"
      ],
      "environment": {
        "SITECORE_LICENSE": "${SITECORE_LICENSE}",
        "SITECORE_APPSETTINGS_ROLE:DEFINE": "ContentDelivery",
        "SITECORE_CONNECTIONSTRINGS_SECURITY": "Data Source=sql;Initial Catalog=Sitecore.Core;User ID=sa;Password=${SQL_SA_PASSWORD}",
        "SITECORE_CONNECTIONSTRINGS_WEB": "Data Source=sql;Initial Catalog=Sitecore.Web;User ID=sa;Password=${SQL_SA_PASSWORD}",
        "SITECORE_CONNECTIONSTRINGS_EXPERIENCEFORMS": "Data Source=sql;Initial Catalog=Sitecore.ExperienceForms;User ID=sa;Password=${SQL_SA_PASSWORD}",
        "SITECORE_CONNECTIONSTRINGS_SOLR.SEARCH": "http://solr:8983/solr",
        "ENTRYPOINT_STDOUT_IIS_ACCESS_LOG_ENABLED": "true",
        "ENTRYPOINT_STDOUT_IIS_ERROR_LOG_ENABLED": "true",
        "ENTRYPOINT_STDOUT_SITECORE_LOG_ENABLED": "true"
      },
      "depends_on": [
        "sql",
        "solr"
      ]
    },
    "cm": {
      "image": "${REGISTRY}sitecore-xm-cm:${SITECORE_VERSION}-windowsservercore-${WINDOWSSERVERCORE_VERSION}",
      "entrypoint": "powershell.exe -Command \"& C:\\\\tools\\\\entrypoints\\\\iis\\\\Development.ps1\"",
      "ports": [
        "44001:80"
      ],
      "environment": {
        "SITECORE_LICENSE": "${SITECORE_LICENSE}",
        "SITECORE_APPSETTINGS_ROLE:DEFINE": "ContentManagement, Indexing",
        "SITECORE_CONNECTIONSTRINGS_CORE": "Data Source=sql;Initial Catalog=Sitecore.Core;User ID=sa;Password=${SQL_SA_PASSWORD}",
        "SITECORE_CONNECTIONSTRINGS_SECURITY": "Data Source=sql;Initial Catalog=Sitecore.Core;User ID=sa;Password=${SQL_SA_PASSWORD}",
        "SITECORE_CONNECTIONSTRINGS_MASTER": "Data Source=sql;Initial Catalog=Sitecore.Master;User ID=sa;Password=${SQL_SA_PASSWORD}",
        "SITECORE_CONNECTIONSTRINGS_WEB": "Data Source=sql;Initial Catalog=Sitecore.Web;User ID=sa;Password=${SQL_SA_PASSWORD}",
        "SITECORE_CONNECTIONSTRINGS_EXPERIENCEFORMS": "Data Source=sql;Initial Catalog=Sitecore.ExperienceForms;User ID=sa;Password=${SQL_SA_PASSWORD}",
        "SITECORE_CONNECTIONSTRINGS_SOLR.SEARCH": "http://solr:8983/solr",
        "SITECORE_APPSETTINGS_TELERIK.ASYNCUPLOAD.CONFIGURATIONENCRYPTIONKEY": "${TELERIK_ENCRYPTION_KEY}",
        "SITECORE_APPSETTINGS_TELERIK.UPLOAD.CONFIGURATIONHASHKEY": "${TELERIK_ENCRYPTION_KEY}",
        "SITECORE_APPSETTINGS_TELERIK.WEB.UI.DIALOGPARAMETERSENCRYPTIONKEY": "${TELERIK_ENCRYPTION_KEY}",
        "ENTRYPOINT_STDOUT_IIS_ACCESS_LOG_ENABLED": "false",
        "ENTRYPOINT_STDOUT_IIS_ERROR_LOG_ENABLED": "false",
        "ENTRYPOINT_STDOUT_SITECORE_LOG_ENABLED": "true"
      },
      "depends_on": [
        "sql",
        "solr"
      ]
    }
  },
  "networks": {
    "default": {
      "external": {
        "name": "nat"
      }
    }
  }
}

If you’re seeing the above error, you’ve included a tab in your JSON file. Wait. Isn’t ‘\t’ a valid JSON character? There’s a pretty good write up here on Stack Overflow: https://stackoverflow.com/questions/55459022/why-docker-compose-cannot-use-tabs-in-json-compatible-mode/55459791

The nuts and bolts break down to this: Docker parses YAML like it is version 1.1, not version 1.2. Version 1.2 allowed for flexibility in tabs, 1.1 was a bit more restrictive. Make sure you don’t include tabs in there, and you should be good to go!

Why would you use JSON over YAML? For me, it came down to parsing. To parse YAML in PowerShell, you needed to snag a third party module. While I’m all for slick things like this, using native JSON parsing out of PowerShell makes more sense. The choice is your, though!

Facebooktwitterredditlinkedinmail