Skip to content
fzakariaPublic

About

An OCI runtime that runs each container in a browser tab.

Topics

Resources

Stars

328 stars

Watchers

1 watching

Forks

Latest commit

 

History

107 Commits

Folders and files

Repository files navigation

tabc

Run containers in a browser tab.

Install · Use · How it works · Hacking · Design

ci

tabc is an OCI runtime, like runc. Where runc starts your container as a Linux process, tabc starts headless Chromium and boots the container inside a tab, on a Linux kernel compiled to WebAssembly. The tab is the sandbox.

docker run with the tabc runtime on Linux, then tabc run on a Mac with no VM running

$ docker run --rm --runtime tabc --platform linux/arm64 alpine uname -sm
Linux aarch64

tabc needs no Linux underneath, so it works on a Mac or on Windows without a VM. With --open the container runs in a tab of your own browser, and what you type in the tab or in the terminal shows in both:

$ tabc run -it --open -p 8123:80 nginx:alpine sh

A terminal above a Chromium window. A tab opens, boots Linux and shows a shell; commands typed in the tab and in the terminal appear in both. nginx starts in the container and a second tab loads its page from localhost:8123.

Compose works too, through tocker, tabc's stand-in for the docker command. Every service is started in their own tab:

$ tocker compose up

A terminal runs tocker compose up; a Chromium window under it shows a pane per service, Redis starting in one and a web server in the other. A second tab loads the web service and its count goes up.

Install

With Nix, on Linux or an Apple Silicon Mac:

$ nix run github:fzakaria/tabc -- run alpine echo hi
hi

Without Nix, each release has an archive for Linux, for a Mac and for Windows, x86-64 and arm64:

$ curl -L https://github.com/fzakaria/tabc/releases/latest/download/tabc-linux-amd64.tar.gz | tar -xz
$ ./tabc-linux-amd64/tabc run alpine echo hi
hi

On Windows 10 or later, in PowerShell:

> curl.exe -LO https://github.com/fzakaria/tabc/releases/latest/download/tabc-windows-amd64.zip
> tar -xf tabc-windows-amd64.zip
> .\tabc-windows-amd64\tabc.exe run alpine echo hi
hi

A release's tabc uses the Chrome or Chromium you have installed, and tocker the docker command line you have installed.

tabc is one file, and tocker is the same file under another name. On Linux the Nix package brings its own Chromium. On a Mac tabc looks for Chrome in /Applications. On Windows tabc looks for Chrome, then Chromium, then Edge, where each installs itself, and tocker is a command file beside tabc.exe. TABC_CHROMIUM names another browser on any of them. With --open the container runs in the browser you already have.

A volume on Windows (-v C:\work:/work) reads the way a Windows directory reads in a container under Docker: every file is root's, with one mode, and chmod changes nothing. docs/design.md has the rest.

Use

On its own

tabc pulls the image and runs it. The flags are the ones you know from docker run.

$ tabc run python:3.13-alpine python -c 'print(6 * 7)'
42
$ echo hello | tabc run -i alpine tr a-z A-Z
HELLO
$ tabc run -p 8080:80 nginx:alpine          # then curl localhost:8080
$ tabc run -v "$PWD":/work -w /work alpine ls
flag what it does
-i, -t keep stdin open, give the program a terminal
-e, -w, -u, -m environment, directory, user, memory
--cpus how many CPUs the guest has, 2 is the default
-p host:container publish a port, on loopback by default
-v dir:/path[:ro] mount a directory, live and writable
--name, --network let containers find each other by name
--network-alias one more name on the container's networks
--open, --link run in your own browser instead of headless

In your browser

$ tabc run -it --open alpine sh

The container opens as a tab you can see, with a terminal in it. Type in the tab or in the terminal you started it from; each shows the other. --link prints the address and waits for you to open it.

Save a container, and start from the save

$ tabc run --name api -v "$PWD":/app my-api   # slow to start
$ tabc park api warm.snap                     # saved; api runs on
$ tabc restore --name api-2 -p 8081:8080 -v ~/other:/app warm.snap

tabc park <container> <file> saves the running guest to a file: the program's memory, mid-step. The container runs on, so it can be saved as often as you like; --stop ends it once the file is written. tabc restore <file> starts a new container where the saved one was. The program does not start again. It carries on in the same process, a second or so after the command.

Told nothing, the new container is the saved one again: same name, ports, networks and volumes. That is a container put to sleep and woken. Told a name, ports, networks or directories for its volumes, it is a copy beside the first, which is how one warm container becomes several.

flag what it does
--name, -p the new container's name and ports
--network, --network-alias its networks, and its names on them
-v dir:/path another directory behind a volume it has
-i, --open, --link as for run

What the program is comes from the file: the image, the command, the environment, whether it has a terminal, its memory and CPUs. The file holds the program's memory and its environment, secrets included, and is written readable by you alone.

A copy does not share the first container's connections: sockets that were open when the guest was saved are reset in the copy. Each copy's kernel reseeds its random numbers, but a program that seeded a generator of its own before the save has the same seed in every copy.

tabc park <container> with no file moves a container you have open in a browser tab (--open, --link) to another tab: the guest stops, and the next browser to open its page resumes it.

Compose, without a Docker daemon

The docker program is only a client: every command is a request to a daemon that remembers which containers exist. A machine without Docker has no such daemon, so tabc includes a minimal one. tocker starts that daemon if it isn't running, then runs the docker client pointed at it, so docker commands work unchanged, Compose included.

$ nix run github:fzakaria/tabc#tocker -- run -it alpine sh
$ tocker compose up
$ tocker exec -it work-web-1 sh   # a shell beside a running program
$ tocker --dashboard compose up   # every service as a pane in one page
$ tocker --stop                   # stop the daemon and its containers

Nothing in your compose.yaml changes. examples/compose is a web server and the Redis it counts its visits in.

With Docker, as its runtime

If you do have Docker, tabc can be the runtime it uses instead of runc. Register it in /etc/docker/daemon.json and restart the daemon:

{ "runtimes": { "tabc": { "path": "/path/to/tabc" } } }

On NixOS that is one line:

virtualisation.docker.daemon.settings.runtimes.tabc.path = "${tabc}/bin/tabc";

Then name it per container:

$ docker run --rm -it --runtime tabc --platform linux/arm64 debian bash

docker exec works on a container started this way, as it does on any other.

For Compose the runtime is a line on each service, not a flag to docker compose up:

services:
  web:
    image: python:3.13-alpine
    runtime: tabc
    platform: linux/arm64

Docker's networks, -p and volumes then work as they do with runc. Podman needs no setup:

$ podman run --rm --runtime /path/to/tabc --platform linux/arm64 alpine echo hi

How it works

  1. The engine, Docker or Podman, calls tabc create as it would call runc.
  2. tabc starts a supervisor, and the supervisor starts headless Chromium with a fresh profile on a page it serves from loopback.
  3. The page boots unkernel, a Linux kernel built for WebAssembly that runs aarch64 programs.
  4. The guest mounts the image. Every file it opens is a request back to the supervisor, which reads it from the bundle or straight out of the image's layers, so the image is never unpacked.
  5. tabc start runs your program in the guest. Its input and output travel over a WebSocket to the supervisor. So does every network connection the program makes; the supervisor opens each one from inside the container's network namespace.
  6. For inbound connections, the supervisor listens on the ports the program opens and carries each connection into the tab.

The engine treats the supervisor as the container, and takes the pid, exit status and stdio from it. docs/design.md has the details.

Hacking

$ nix build                # the runtime, one file
$ nix flake check          # unit tests, and containers in a real Chromium
$ nix build .#tabc-darwin  # a Mac binary, built on Linux
$ nix fmt                  # before committing

Credits

unkernel by Pooya Parsa does the hard part: Linux as a WebAssembly module, and the SDK that boots it.

License

MIT, please see LICENSE. unkernel's kernel is GPL-2.0.

About

An OCI runtime that runs each container in a browser tab.

Topics

Resources

Stars

328 stars

Watchers

1 watching

Forks

Releases

Sponsor this project

Packages

Contributors

Languages