Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot debug dotnet Docker amd64 container on host OSX M2 #4009

Closed
eitanbehar opened this issue Jul 16, 2023 · 11 comments
Closed

Cannot debug dotnet Docker amd64 container on host OSX M2 #4009

eitanbehar opened this issue Jul 16, 2023 · 11 comments

Comments

@eitanbehar
Copy link

Type: Bug

  1. On a MacBook Pro OSX M2
  2. Follow guide from VSCode documentation:
    https://code.visualstudio.com/docs/containers/debug-netcore
  3. Change base image to platform linux amd64
    FROM --platform=linux/amd64 mcr.microsoft.com/dotnet/runtime:6.0

Extension version: 1.25.2
VS Code version: Code 1.80.0 (Universal) (660393deaaa6d1996740ff4880f1bad43768c814, 2023-07-04T13:39:33.766Z)
OS version: Darwin arm64 22.5.0
Modes:

System Info
Item Value
CPUs Apple M2 Pro (12 x 24)
GPU Status 2d_canvas: enabled
canvas_oop_rasterization: disabled_off
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
metal: disabled_off
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
video_decode: enabled
video_encode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: enabled
Load (avg) 1, 2, 2
Memory (System) 32.00GB (0.15GB free)
Process Argv
Screen Reader no
VM 0%
@alexyaang
Copy link
Member

alexyaang commented Jul 17, 2023

@eitanbehar What is the error message you're seeing?

@eitanbehar
Copy link
Author

eitanbehar commented Jul 17, 2023

@alexyaang there is no error (at least I don't see it), the container runs, but the breakpoint is faded out with message that "no symbols have been loaded"
there is a warning: "WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested
Note that if I remove --platform=linux/amd64 then it will run/debug smoothly.
If it helps, I can provide a full working example

@bwateratmsft
Copy link
Collaborator

It's possible that an Apple Silicon Macbook is not capable of debugging an amd64 container. We should investigate @alexyaang.

@alexyaang
Copy link
Member

@eitanbehar Thanks for providing more info! I'll do some investigating since I have a M1 Mac as well. 👍

@bwateratmsft That is a possibility. time to try it myself

@eitanbehar
Copy link
Author

@alexyaang thanks for looking into this, please, let me know if more details are needed.

@alexyaang alexyaang self-assigned this Jul 17, 2023
@alexyaang
Copy link
Member

@eitanbehar I was able to replicate this issue and I think I know why. 😄 Can you drop the contents of your launch.json, tasks.json, and your Dockerfile? And to confirm, your project is targeting .NET 6, correct?

@eitanbehar
Copy link
Author

@alexyaang sure, adding the whole project for better share
https://github.com/eitanbehar/docker-samples/tree/main/httpListener

@dbreshears dbreshears added this to the 1.27.0 milestone Jul 19, 2023
@alexyaang
Copy link
Member

alexyaang commented Jul 19, 2023

@eitanbehar After further investigation, it seems that the core issue lies in the inability for our debuggers to debug an amd64 container on an arm64 machine. This explains why, when you remove the --platform=linux/amd64 flag, debugging works as expected.

Without the --platform flag, Docker automatically determines the platform based on the architecture and settings of your computer. In your case, it defaults to linux/arm64, allowing you to successfully debug because you are on an arm64 machine. Consequently, this appears to be a debugger-related problem. I'm going to mark this as a duplicate of #2884.

Like you mentioned, removing the --platform=linux/amd64 flag will fix your issue (if you debug a arm64 container). But unfortunately, I'm not aware of a good solution to debug an amd64 .NET container on an arm64 machine currently.

Thank you for your cooperation and bringing this to our attention :)

@eitanbehar
Copy link
Author

@alexyaang thanks your efforts on this. So if I understand correctly, this scenario is not currently supported, do you happen to know if there is a plan to address it in a near future. I am not looking for a commitment, just your gut feelings on this.
Btw, I found this note in the release notes for net7, which might be related:
".NET 7 is not supported being run (emulated) via QEMU. QEMU is used, for example, to emulate Arm64 containers on x64, and vice versa."
https://github.com/dotnet/core/blob/main/release-notes/7.0/supported-os.md#qemu
Thanks again, Eitan

@alexyaang
Copy link
Member

@eitanbehar Your understanding is correct. I believe this scenario is not supported in .NET 6 or .NET 7.

However, progress is being made in .NET 8 :) dotnet/dotnet-docker#4388 (comment)

@bwateratmsft
Copy link
Collaborator

I'll close this as a dupe of #2884. Hopefully this becomes available soon!

@bwateratmsft bwateratmsft closed this as not planned Won't fix, can't repro, duplicate, stale Jul 26, 2023
@bwateratmsft bwateratmsft removed this from the 1.27.0 milestone Jul 26, 2023
@microsoft microsoft locked and limited conversation to collaborators Sep 10, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants