This reads a bit like "when all you have is a hammer" because it seems like what you want is a VM, not a container[^1]. Have you considered using VM software instead of Docker and using an Ubuntu VM directly? Some options:
https://orbstack.dev/ (using its "machines" functionality)
[^1]: Of course macOS docker is running a Linux VM under-the-hood, but that's an implementation detail.