I use Containise for that, it lets you set wildcards: https://addons.mozilla.org/en-US/firefox/addon/containerise/
Unfortunately that doesn't open other links outside the container :/
Temporary containers will do that https://addons.mozilla.org/en-US/firefox/addon/temporary-con...
All urls that are not "pinned" to a container open in a temporary container.
My problem with that is that, even if I do this, it doesn't remember it for foo.abc.com, and when I'm in the container, links to def.com won't open outside the container.