Questions about DevContainers

I have a customization project that we developed before Critical Manufacturing recommended using DevContainers in VSCode. As an experiment, I regenerated the scaffold for the project and noticed that it produced a .devcontainer folder with meaningful content. Here are some questions/observations I have:

  1. I generated the scaffold by running the cmf init and cmf new commands from powershell prompt in the Window OS of my laptop. I opened the project in VS Code and then executed the command for re-opening it in a DevContainer. I have Docker Desktop licensed and running in Windows and the DevContainer started up without issue. This seems to be different from what the directions from CM indicate. I think those directions suggest installing a docker daemon inside of WSL. Is the approach that I’ve taken also valid?
  2. To test out my customizations, I normally would run cmf dev local stack up from a command prompt in my Windows OS. With DevContainers, can I run this command from the dev container prompt? Actually, I’ll try this and report back on what I find.
  3. Does debugging of customizations change when using DevContainers? In the past, I would open the Business solution in Visual Studio Pro and attach the debugger to the host container. It seems like this would still need to be the case even if using DevContainers for the build.

Hi Ben,

It’s great that you’re experimenting with the new devcontainer scaffold. Let’s go through your questions about the DevContainer:

Topic 1: Docker Desktop vs. WSL2 Daemon

You are correct that Docker Desktop will work and it’s a valid approach for running DevContainers and your CMF stack. The reason the official CM guides recommend setting up the Docker daemon inside of WSL2 (using a distribution like Ubuntu) is primarily due to licensing and performance.

Licensing: As you noted, Docker Desktop has specific licensing requirements for commercial use in larger organizations, which may not apply to every developer. The WSL2-based setup avoids this dependency.

Performance: Critically, running the DevContainer’s required Docker commands is significantly faster when the DevContainer and the Docker daemon are both running within the WSL2 filesystem. This avoids the performance penalty associated with mapping the Windows filesystem into Linux containers.

In short, your approach is valid and functional, but the recommended path (WSL2 with Docker daemon installed there) provides better long-term cost-effectiveness and performance for the build and deployment steps.

----Topic 2: Running cmf dev local stack up

Your intuition is correct:

Execute inside the DevContainer: Yes, all CM-specific commands, including cmf new, cmf build, cmf dev local stack up, cmf … should be executed inside the DevContainer terminal.

Why? The DevContainer is specifically configured to have all the necessary CM tooling, .NET SDKs, and environment variables pre-installed, ensuring a consistent and isolated build environment.

VS Code Tasks: To make this easier, your newly scaffolded project includes a .vscode/tasks.json file. You can use the VS Code Command Palette (Ctrl+Shift+P or Cmd+Shift+P) to run predefined tasks like “Stack Up” directly, which simplifies the process and avoids having to manually type the commands in the terminal.

Topic 3: Debugging Customizations

This is where the DevContainer significantly simplifies the backend debugging experience compared to previous workflow!

Backend Debugging (VS Code): You do not need to attach Visual Studio Pro to the host container anymore for C# debugging.

The CM DevContainer setup includes the necessary VS Code extensions to allow you to debug your C# business logic directly from VS Code. There are still manual steps, that may be enhanced in future, e.g. setup of launch.json.

You can set breakpoints in your C# files and use the standard VS Code Run and Debug interface (usually the side-bar icon) to attach to the running CMF service inside the container, offering a seamless experience. This is what the Development Workflow section of the CMF documentation refers to.

Visual Studio (Alternative): While the recommended approach is VS Code debugging, you can still use Visual Studio Pro if you prefer. However, this involves a few extra steps (as you noted) to configure remote debugging and port mapping, which Critical Manufacturing does not officially support or provide documentation for, as the primary workflow is now centered on the VS Code DevContainer environment. If you are able to understand current architecture, you should be able to setup the environment using Microsoft instructions to debug .NET containers using Microsoft Visual Studio.

Keep us posted on your progress.

Best regards,

João Moreira

Thank you, João, for the information. This is very helpful. You mentioned (in topic 2) that there ought to be a .vscode/tasks.json file generated with the scaffolding. I do not see such a file in my project. Do you know why this would be?