Wednesday, January 1, 2025

XMC how to fix a network with name ABC-xmc_default exists but was not created by compose

Recently during the new XMC project setup, I got below error

 Starting Sitecore environment...

 level=warning msg="a network with name ABC-xmc_default exists but was not created by compose.\nSet `external: true` to use an existing network"

network ABC-xmc_default was found but has incorrect label com.docker.compose.network set to ""

You cannot call a method on a null-valued expression.

At C:\Projects\ABC-xmc\docker\add-host.ps1:8 char:1

+ $containerId = $containerId.Replace("failed to get console mode for s ...

+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    + CategoryInfo          : InvalidOperation: (:) [], ParentContainsErrorRecordException

    + FullyQualifiedErrorId : InvokeMethodOnNull

Fix

Go to your docker compose overide file and at the last add this lines


networks:
  default:
    external: true
    name: ABC-xmc_default