Running Chrome or Chromium in a container is incredibly useful to run tests, build web scrapers, or to make screenshots of web pages - but unfortunately installing Chromium is no longer supported using `apt` on Ubuntu:
```
$ apt update && apt install -y chromium-browser
$ chromium-browser
Command '/usr/bin/chromium-browser' requires the chromium snap to be installed.
Please install it with:
snap install chromium
```
This is problematic because snap does not work from within a Docker container. There are some other options:
Another big issue with these approaches is that there's no versioning. You'll always get the latest version of Chrome / Chromium. Fine if you're just visiting websites on your laptop, but if you use this in your test infra or in production then this might break your tests or application any time the container gets rebuilt.
To fix this we've built StableBuild. We mirror the complete Ubuntu and Debian package registries (plus a lot more!) every day, and thus let you easily install _specific_ Chromium versions on Ubuntu (by pinning to a specific date of the Debian package registry). Here's how it works:
And done!
You now have a working version of Chromium in your container (here ran on Ubuntu 22.04 with pin date 2023-12-09T10:40:02Z):
```
$ chromium --version
Chromium 116.0.5845.180 built on Debian 12.1, running on Debian bookworm/sid
```
In addition Chromium is now pinned. This container will now always install Chromium 116, and thus your containers won't randomly break due to an unsupported or untested update.
If you also need Chromedriver, e.g. to run tests, then run:
```
$ apt install -y chromium-driver
```
🎉
Note: A downside is that you're constrained to Chromium versions that are published in the Debian package registry (as that's what we mirror), which typically is behind the latest stable version. E.g. on the 2023-12-09 pin date above the Debian registry contains Chromium 116, while Chromium 120 has already been released on other channels.