SYS_Ptrace Capability for Linux/AMD64


I have an M2 Macbook that is running Docker Desktop and I’d like to be able to debug linux/amd64 binaries in linux/amd64 containers.

Debugging under qemu directly or UTM works fine. So I know it is not a Qemu limitation. I even tried hard-swapping the Qemu binary on my system with the Qemu binary packaged with Docker. I also recently tried enabling the new Rosetta emulation support.

However, when I attempt to run something like

docker run --cap-add=SYS_PTRACE --privileged --platform linux/amd64 -ti amd64/ubuntu:latest /bin/bash
# apt-get update && apt-get install -y gdb
# gdb /bin/bash

I get the following error message

Cannot PTRACE_GETREGS: Input/output error

Anyone been anble to succesfully debug linux/amd64 binaries in a linux/amd64 container while running on M1/M2/M3.


Your commands worked for me with and without Rosetta, so it worked with Qemu too. MacBook Air (M1). gdb /bin/bash gave me no error.


gdb > break *main
gdb > r

That gives me the error (with rosetta)

Couldn't get registers: Input/output error

It looks like it is a known issue on Mac

The last issue in the list is in the Docker DEsktop for Mac repo. I recommend joining the conversation there too.

It’s weird because when I use default emulation it will give an error about SYS_PTRACE not implemented. But qemu has absoluted implemented sys_ptrace because I can run and build qcow images to support debugging amd64 on ARM.

Rosetta complains because of PTRACE_GETREGS fails.

I was really hoping when the enabled Rosetta support it would fix this.