Why Chrome Forgets Its Tabs in a Container — And How I Fixed It
Description and use
Chrome in a Docker container starts with a blank tab after each restart. A startup script saves open tabs every 60 s and restores them on the next launch, eliminating context loss.
Problem
Chrome in a Docker container always starts with a single blank tab after a restart, losing the user’s open tabs.
Outcome
After implementing the tabs_keeper.py script, the Chrome container reliably restores the last session on every restart, eliminating the 10‑minute context rebuild period.
Workflow
- 1. Detect browser startup and check if any real page is open.
- 2. If no page is open, read the last‑known tab URLs from a snapshot file and open them via the CDP.
- 3. Every 60 s, query the CDP for current tab URLs and write them to the snapshot file.
- 4. Run this script as a container‑init hook so it starts automatically with the container.
Evidence
Every time the container restarts, the browser comes back with a single blank tab.
Chrome’s restore machinery needs a session it considers interrupted or resumable.
The data was never missing. The profile’s session directory was being written continuously, seconds apart, the whole time.
- Record date: 2026-11-01T09:14:03.300Z