Automatically Opening Firefox Bookmarks in Specific Multi-Account Containers

For quite some time now, Firefox has had a function called Multi Account Containers built into it. This allows you to launch tabs inside a container (whether dedicated to that tab, or shared with some others) so that cookies, locally stored objects etc are only available within the container.

Essentially, it allows you to isolate sites/domains into their own little playground, away from anything else you might want to visit.

The functionality allows you to (quite trivially) set a domain to always open within a specific container - so you could (for example) set Facebook to always switch to a container, making it harder for them to track you when you visit other sites (because you'll not be logged into FB in the referring container).

Setting Facebook to use a specific container

Which is, to say the least, very useful.

It's not just privacy benefits you gain though, particularly if you're in IT.

Individual containers can also be configured to use different proxy settings. If you're supporting widely distributed kit that you reach through different proxies (SSH tunnels for example), rather than messing around switching Firefox's settings around (though I used to use FoxyProxy), you can simply configure the relevant domain to open in a preconfigured container.

However, there's a pretty key (IMO) bit of functionality missing: there's no native way to set a bookmark to always open in a specific container. There's been a feature request open against Firefox for quite some time to enable this, but there's been no real movement to date.

This documentation details how to set Firefox up so that a bookmark can specify the container it should open in, using a small third party addon to provide a custom protocol handler.


Whilst you can set a domain to always open in a container, that's not granular enough for some use-cases. In some cases, you need to be able to open the same domain in multiple different containers.

I suspect almost anyone in IT will be familiar with the first example: Vendor AcmeCorp has a website. You need to be able to log into AcmeCorp using multiple accounts (dev & prod, or multiple customer accounts etc).

Without the ability to do this, you can't multi-task. Using Private/Incognito mode allows you to log into a second account, but that's not always enough and using a second browser really is using a sledgehammer to crack a nut.

There's a use-case related to the earlier proxy example too: sometimes you need to access different kit, on different sites, via the same hostname (and just be connected via a different tunnel/proxy). Yes, it shouldn't happen but it does. Simply setting the domain to open in a container isn't sufficient for this use-case, you need a higher level of granularity.

As a less IT dept centric example, Gmail is easily understandable: you have multiple accounts and want each inbox open in a seperate browser tab.

Firefox's multi-account containers can address these use-case, but the process you'd need to follow each time is

  • Click and hold on the new tab + button
  • Choose a container
  • Browse to Gmail/AcmeCorp/wherever
  • Login
  • Repeat process for the other tab

Which is horribly unwieldy and inconvenient, screaming out for automation.

That automation is what we're going to set up in this document.

Setting up Multi-Account Containers

If you haven't already, you need to enable Firefox's containerisation management.

The underlying container functionality is already built into Firefox, but to manage it you need an extension. Technically, you can do it without the add-on, but it's not recommended.

Install Mozilla's Firefox Multi-Account Containers Add-on

You'll now have the containers add-on in your toolbar

Firefox Multi-Account Containers addon icon

This allows you to view and create containers.

The same icon will also appear in the address bar - this allows you to set a specific domain to always open in a specific container.

Setting Facebook to use a specific container

Which is good, but not quite what we need.

Setting up the functionality

The add-on Open external links in a container is essentially a custom protocol handler, allowing us to use a special syntax in our bookmarks to identify a container.

So, install the add-on.

Once it's enabled, we can build an URL for our bookmark using the following format

ext+container:name=[Container_name]&url=[bookmarked url]

The container you specify doesn't need to be pre-created - it'll be created the first time you try and use it. You can also optionally add a color option to control what color the container tab uses (it supports icon too).

So, for each account, you then create a slightly different url, and create a bookmark for each:

  • ext+container:name=Gmail_account_1&color=orange&url=
  • ext+container:name=Gmail_account_2&color=purple&url=

I've named these Gmail main account and Gmail second account so that firefox suggests them when I start typing Gmail into the address bar. That way, I don't need to go off to the bookmarks menu to use them.

I can now launch both, and log into each account simultaneously

Firefox Multi-Account Containers allows simultaneous login to two accounts

Although drifting out of the scope of this document a little, it's not just bookmarks that you can use this syntax for. For example, if you're invoking Firefox from a shell, you can specify the container to open your URL in

firefox 'ext+container:name=data_leeches&icon=fruit&url='

For those interested, the source code of the extension is available at

Configuring proxies

If you landed on this page because you want to be able to use different proxies in different containers, this section's just for you!

  • Click the Containers icon in the toolbar, and choose Manage Containers
  • Click the container you want to configure
  • Click Advanced Proxy settings

You'll be asked to grant an additional permission: allowing the add-on to manage proxy settings. It should be obvious why this is required.

You can then go back into the menu, and this time, when you click Advanced Proxy Settings you'll see the following dialog

Container Advanced proxy settings

You can enter your proxy url here. I've not found an official document documenting the accepted proxy url schemes, but we can infer it from the code:

const proxyRegexp = /(?<type>(https?)|(socks4?)):\/\/(\b(?<username>\w+):(?<password>\w+)@)?(?<host>((?:\d{1,3}\.){3}\d{1,3}\b)|(\b([\w.-]+)+))(:(?<port>\d+))?/;

The types supported by that regex are therefore

  • http
  • https
  • socks
  • socks4

If you need to provide credentials, you can include them in the proxy URL.

So, assuming I've run

ssh -D 8080 somewhere

I might set a proxy url of socks://, or if (for some reason) I didn't want my DNS lookups to use the tunnel, I could force Socksv4 with socks4://


Firefox's Multi-Account container functionality is incredibly useful - it continues to surprise me that Chrome continues to lack similar functionality.

Whilst Firefox's MAC feature can help support a wide array of fairly common use-cases, it is currently lacking a bit in granularity, so to really get the most out of it, you need a third party extension.

With that extension, you can then effectively configure bookmarks to open in specific containers, simplifying quite a number of use-cases.