Skip to main content

SitecoreAI · Tutorial

Running Sitecore XMC Locally with Docker

The PowerShell lifecycle for XMC's local container stack, and how to fix the start-up errors you'll hit when it's left in a bad state.

GavAusWeb2 min read

Coming from a pure front-end workflow, the first mental shift into Sitecore XMC is treating your local environment as a multi-container stack you have to manage, not just an npm run dev. Sitecore's containerized setup ships with PowerShell scripts to bring the stack up and down cleanly, and learning that lifecycle early saves you a lot of afternoon debugging.

The daily lifecycleLink to this section

  1. Step 1: Bring the stack up

    On your first run of the day, bring the full stack up from scratch:

    ps1
    .\up.ps1
  2. Step 2: Use the quick start for later restarts

    Once everything has run once, use the quick script on later starts within the same session to skip some of the slower provisioning steps:

    ps1
    .\up-quick.ps1
  3. Step 3: Shut down cleanly at the end of the day

    Get in the habit of running .\down.ps1 at the end of every day, before your VM or machine shuts down. This isn't optional housekeeping — Docker networks and containers left in a half-torn-down state are the single biggest source of 'why won't this start' pain the next morning.

    ps1
    .\down.ps1

    The down.ps1 script stops the stack and then prunes Docker, so nothing stale carries over to tomorrow:

    ps1
    Write-Host "Down containers..." -ForegroundColor Green
    try {
      docker compose down
      ECHO 'y' | docker system prune
      if ($LASTEXITCODE -ne 0) {
        Write-Error "Container down failed, see errors above."
      }
    }
    finally {
    }

Fixing start-up errorsLink to this section

After an unclean shutdownLink to this section

If you forget and the VM closes on you anyway, you'll hit errors on the next up. Bring it down, remove the leftover network by hand, then start again:

ps1
.\down.ps1
docker network rm your-project_default
.\up.ps1

Solr errorsLink to this section

If you see a Solr error specifically, don't fight it — run .\down.ps1, reset the VM entirely, then once it's back up run .\up.ps1. It's a faster fix than trying to debug Solr's container state directly.

An unhealthy containerLink to this section

If a container comes up unhealthy (commonly cm-1), don't just retry the up script. Clear stale volumes, layers and networks, then bring it back up:

ps1
docker compose down -v
docker system prune -f
.\up.ps1

Restarting a single containerLink to this section

You don't always need to tear down the whole stack. Grab the misbehaving container's ID from docker ps and restart just that one — or stop and start it if a plain restart doesn't clear it:

ps1
docker ps
docker container restart <id>

docker container stop <id>
docker container start <id>

Corrupted layer cacheLink to this section

If a build fails with something like 'COPY failed: hcsshim::PrepareLayer failed in Win32: The container image contains a layer with an unrecognized format', it's usually a corrupted layer cache. A deeper clean resolves it before you rebuild:

ps1
docker system prune -a