---
title: "Debug code running in XC containers"
slug: "debug-code-running-in-xc-containers"
abstract: "This topic shows how to debug Commerce Engine code that is running in a container."
---
# Debug code running in XC containers

This topic explains how to use [Visual Studio to view and diagnose](https://docs.microsoft.com/en-us/visualstudio/containers/view-and-diagnose-containers?view=vs-2019) your Commerce Engine code when it is running in a local Docker container. It assumes that you know how to [build and run custom Docker runtime images](https://doc.sitecore.com/xp/en/developers/103/sitecore-experience-commerce/workflow-for-creating-custom-commerce-container-images.html "Workflow for creating custom Commerce container images") that include the build output for your Commerce solution.

To debug apps in a local Docker container, you must use Visual Studio 2019 version 16.5.0 or later.

> [!note]
> Though not unique to containers, you must ensure that debug symbols have been deployed to the container. This might already be done if you are building your solution image with the *Debug* build configuration.
>
> You can also do a *Debug* file deployment from Visual Studio into the running container.

In Visual Studio, you have two options for attaching the debugger to a process in a container:

- [Option 1: Attach the Visual Studio debugger using the Containers window](https://doc.sitecore.com/xp/en/developers/103/sitecore-experience-commerce/debug-code-running-in-xc-containers.html#UUID-132c6a74-57fe-e712-d3f7-c5e081463af8_N1615906914713 "Option 1: Attach the Visual Studio debugger using the Containers window")
- [Option 2: Attach the Visual Studio debugger using the Debug menu](https://doc.sitecore.com/xp/en/developers/103/sitecore-experience-commerce/debug-code-running-in-xc-containers.html#UUID-132c6a74-57fe-e712-d3f7-c5e081463af8_section-idm253231813139422 "Option 2: Attach the Visual Studio debugger using the Debug menu")

<details>
<summary><h2>Option 1: Attach the Visual Studio debugger using the Containers window</h2></summary>

To attach the Visual Studio debugger to a process running in a container:

1. If the **Containers** window is not showing, open it from the top **View** menu. Click **Other Windows**, then **Containers**.
2. In the list of running containers, right-click the one that you want to debug, for example *container_engine_authoring_1*, and click **Attach to Process**:

    ![In Visual Studio, the Attach to Process option in the dialog box containing debugging actions.](https://doc.sitecore.com/api/markdown-image/xp/en/developers/103/sitecore-experience-commerce/images/AttachToProcess.png)

    The **Attach to Process** dialog opens.

3. In the **Attach to Process** dialog, to debug a Commerce Engine **dotnet.exe** process, use code type **Automatic: Managed(.NET Core, .NET 5+)code**, as shown in the following example:

    ![The Attach to Process dialog box with the dotnet.exe process selected.](https://doc.sitecore.com/api/markdown-image/xp/en/developers/103/sitecore-experience-commerce/images/Available_Process.png)

4. Click **Attach**.

</details>

<details>
<summary><h2>Option 2: Attach the Visual Studio debugger using the Debug menu</h2></summary>

Alternatively, you can use the Visual Studio Debug menu.

To attach the Visual Studio debugger to a process running in a container:

1. In Visual Studio, in menu bar, click **Debug**, and then click **Attach to Process**. The **Attach to Process** dialog box opens.
2. In the **Connection type**, drop-down list, click **Docker (Windows Container)**.
3. In the **Connection target** field, click **Find**. Running containers appear in the list. Click the container you want to debug, and click **OK**.
4. In the **Attach to** field, select the correct type. To debug a Commerce Engine `dotnet.exe` process, use code type **Automatic: Managed(.NET Core, .NET 5+)code**.
5. Click **Attach**.

</details>