I don’t have any experience with Unifi … but I’ve read in another thread that Unifi controler is a pretty fat application which requires more than 1GB RAM to run. RB5009 has only got 1GB (and some of it is required to run ROS and do some firewalling/routing). So it might be that unifi controller is simply too fat to be run on RB5009 (and many other, most Mikrotiks come with 1GB of RAM or less).
That is what I think in new routerOS is memory handling more safe…
It is definitely true that all unifi consoles have at least 2Gb RAM.
But for example Banana Pi device with 1Gb ram can run unifi controller and managment of 35 devices wothout any issue.
And there is one more thing
The container was running on older routerOS.