Who needs VMs? Run systemd and full Linux desktop apps in gVisor
Since: Mon 2026-08-10 19:29:51 UTC; 5s ago
以下正文同步自 Hacker News 最新,版权归原站所有,已转换为易读排版。
$ docker exec -it dev bash root@dev:/# uname -r 4.19.0-gvisor root@dev:/# head -4 /etc/os-release PRETTY_NAME="Ubuntu 26.04 LTS" NAME="Ubuntu" VERSION_ID="26.04" VERSION="26.04 LTS (Resolute Raccoon)" root@dev:/# systemctl status ● dev State: running Units: 180 loaded (incl. loaded aliases) Jobs: 0 queued Failed: 0 units Since: Mon 2026-08-10 19:29:51 UTC; 5s ago systemd: 259.5-0ubuntu3.3 Tainted: unmerged-bin:old-kernel CGroup: / ├─init.scope │ ├─ 1 /sbin/init │ ├─46 bash │ ├─48 systemctl status │ └─49 "(pager)" └─system.slice ├─dbus.service │ └─43 @dbus-daemon --system --address=systemd: --nofork --nopidfile --systemd-activation --syslog-only ├─systemd-journald.service │ └─18 /usr/lib/systemd/systemd-journald └─systemd-logind.service └─44 /usr/lib/systemd/systemd-logind
systemd is running normally in gVisor, with a full-system Ubuntu container. As a first service, let’s try installing OpenSSH and creating a user:
root@dev:/# apt update && apt install -y openssh-server root@dev:/# systemctl enable --now sshd root@dev:/# useradd --create-home --shell $SHELL chert root@dev:/# echo ember | passwd chert --stdin root@dev:/# gpasswd -a chert sudo root@dev:/# exit
Now on the host we can ssh into the container as if it were a normal Linux VM:
$ ssh -p 2222 chert@127.0.0.1 Are you sure you want to continue connecting (yes/no/[fingerprint])? yes Warning: Permanently added '[127.0.0.1]:2222' (ED25519) to the list of known hosts. chert@127.0.0.1's password: Last login: Mon Aug 10 19:40:46 2026 from 172.17.0.1 chert@dev:~$
This is useful, for example, as a full-system development container when the code being worked on or its dependencies are untrusted, perhaps as part of a CI/CD pipeline.
Let’s try building CUPS, a printing server for Unix-like systems, in our new development container. First, let’s clone the source code and install build dependencies:
chert@dev:$ sudo apt install -y autoconf build-essential $ wget 'https://github.com/OpenPrinting/cups/releases/download/v2.4.19/cups-2.4.19-source.tar.gz'
chert@dev:
avahi-daemon libavahi-client-dev
libssl-dev libkrb5-dev libnss-mdns libpam-dev
libsystemd-dev libusb-1.0-0-dev zlib1g-dev unzip
chert@dev:$ tar xvf cups-2.4.19-source.tar.gz
chert@dev:$ cd cups-2.4.19/
chert@dev:/cups-2.4.19$ ./configure --with-systemd=/lib/systemd/system --libdir=/usr/lib/x86_64-linux-gnu
chert@dev:/cups-2.4.19$ make -j$(nproc)
chert@dev:~/cups-2.4.19$ sudo make install
Notice that the systemd unit files have been installed:
chert@dev:/cups-2.4.19$ sudo systemctl list-unit-files | grep cups
cups.path enabled enabled
cups-lpd@.service static -
cups.service enabled enabled
system-cups.slice static -
cups-lpd.socket disabled enabled
cups.socket enabled enabled
chert@dev:/cups-2.4.19$
And we can enable and start the CUPS service directly, as with a normal Linux VM:
chert@dev:/cups-2.4.19$ sudo systemctl enable --now cups
Created symlink '/etc/systemd/system/printer.target.wants/cups.service' → '/usr/lib/systemd/system/cups.service'.
Created symlink '/etc/systemd/system/multi-user.target.wants/cups.service' → '/usr/lib/systemd/system/cups.service'.
Created symlink '/etc/systemd/system/sockets.target.wants/cups.socket' → '/usr/lib/systemd/system/cups.socket'.
Created symlink '/etc/systemd/system/multi-user.target.wants/cups.path' → '/usr/lib/systemd/system/cups.path'.
chert@dev:/cups-2.4.19$ sudo systemctl status cups
● cups.service - CUPS Scheduler
Loaded: loaded (/usr/lib/systemd/system/cups.service; enabled; preset: enabled)
Active: active (running) since Thu 2026-09-03 18:39:47 UTC; 4h 17min ago
Invocation: beac14c3deb245bb9db702ee186dfbc5
TriggeredBy: ○ cups.path
● cups.socket
Docs: man:cupsd(8)
Main PID: 16097 (cupsd)
Status: "Scheduler is running..."
Tasks: 1 (limit: 9830)
Memory: 2.3M
CGroup: /system.slice/system-cups.slice/cups.service
└─16097 /usr/sbin/cupsd -l
Sep 03 18:39:47 dev systemd[1]: Starting cups.service - CUPS Scheduler... Sep 03 18:39:47 dev systemd[1]: Started cups.service - CUPS Scheduler.
GNOME in gVisor
We’re not just limited to using the command-line in our sandboxed developer workstation, though. While hosting a full-system container, gVisor can now run a full sandboxed desktop environment. To showcase this, let’s set up a gVisor container with the popular GNOME desktop environment.
The gVisor repository contains the Docker image images/systemd-user/systemd-debian-gnome for this purpose. In the gVisor repository we cloned earlier:
Build & run the systemd-debian-gnome container in gVisor
$ docker build -t systemd-debian-gnome
-f images/systemd-user/systemd-debian-gnome/Dockerfile.x86_64
images/systemd-user/systemd-debian-gnome
$ docker run -d --name gnome --runtime=runsc --shm-size=1g --privileged -p 127.0.0.1:3389:3389 systemd-debian-gnome
The sandboxed GNOME workstation is exposed through RDP on port 3389, which can be accessed using an RDP client such as Remmina by connecting to 127.0.0.1:3389. The default username/password is gnome:gnome.
We can even browse the web in the sandbox:
Or, to go full circle, we can develop gVisor inside of gVisor:
In addition to Debian-based distributions, RHEL-based images work too. For example:
$ docker run -d --runtime=runsc --privileged --name dev-rhel --hostname dev-rhel registry.access.redhat.com/ubi10/ubi-init $ docker exec -it dev-rhel bash [root@dev-rhel /]# uname -r 4.19.0-gvisor [root@dev-rhel /]# head -2 /etc/os-release NAME="Red Hat Enterprise Linux" VERSION="10.2 (Coughlan)" [root@dev-rhel /]# systemctl status ● dev-rhel State: running Units: 119 loaded (incl. loaded aliases) Jobs: 0 queued Failed: 0 units Since: Fri 2026-09-04 19:57:08 UTC; 7min ago systemd: 257-23.el10_2.2-g009f2a8 Tainted: old-kernel CGroup: / ├─init.scope │ ├─ 1 /sbin/init │ ├─54 bash │ ├─68 systemctl status │ └─69 "(pager)" └─system.slice └─systemd-journald.service └─14 /usr/lib/systemd/systemd-journald [root@dev-rhel /]#
Ansible
Ansible is a tool for provisioning and deploying software. Many Ansible roles expect a full Linux system, with a running service manager (like systemd). This presents a problem for testing, since CI pipelines can be difficult to keep secure, and native containers running systemd often require large amounts of privilege.
Full-system containers with gVisor sidestep this problem by allowing a VM-like container to be provisioned for each test run. Multiple gVisor containers can be run on a single host without sharing a kernel, making this setup much more secure.
To demonstrate, let’s do a test run of Jeff Geerling’s nginx role, which installs nginx and starts it as a systemd service, in gVisor.
Let’s continue in our dev container we created earlier:
$ ssh -p 2222 chert@127.0.0.1
chert@dev:$ sudo apt install -y ansible git
...
chert@dev:$ sudo git clone https://github.com/geerlingguy/ansible-role-nginx /etc/ansible/roles/geerlingguy.nginx
chert@dev:~$ cat > playbook.yml <<'EOF'
- name: Install nginx with geerlingguy.nginx hosts: all become: true
pre_tasks:
- name: Update apt cache. ansible.builtin.apt: update_cache: true cache_valid_time: 600 changed_when: false
roles:
- role: geerlingguy.nginx EOF chert@dev:~$ sudo ansible-playbook -i localhost, -c local playbook.yml
Expand to see the Ansible playbook output.
PLAY [Install nginx with geerlingguy.nginx] **************************
TASK [Gathering Facts] *********************************************** [WARNING]: Host 'localhost' is using the discovered Python interpreter at '/usr/bin/python3.14', but future installation of another Python interpreter could cause a different interpreter to be discovered. See https://docs.ansible.com/ansible-core/2.20/reference_appendices/interpreter_discovery.html for more information. ok: [localhost]
TASK [Update apt cache.] ********************************************* ok: [localhost]
TASK [geerlingguy.nginx : Include OS-specific variables.] ************ ok: [localhost]
TASK [geerlingguy.nginx : Define nginx_user.] ************************ ok: [localhost]
TASK [geerlingguy.nginx : include_tasks] ***************************** skipping: [localhost]
TASK [geerlingguy.nginx : include_tasks] ***************************** included: /etc/ansible/roles/geerlingguy.nginx/tasks/setup-Ubuntu.yml for localhost ... chert@dev:~$
Now that the playbook has run and installed nginx, observe that systemd is managing nginx just like on a normal Linux VM:
Expand to see the systemctl status nginx output.
chert@dev:~$ sudo systemctl status nginx ● nginx.service - A high performance web server and a reverse proxy server Loaded: loaded (/usr/lib/systemd/system/nginx.service; enabled; preset: enabled) Active: active (running) since Fri 2026-09-04 21:11:21 UTC; 1min 10s ago Invocation: f42bafe5b01a412f8c8a961eec0cf957 Docs: man:nginx(8) Process: 2397 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=0/SUCCESS) Process: 2398 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (code=exited, status=0/SUCCESS) Process: 2437 ExecReload=/usr/sbin/nginx -g daemon on; master_process on; -s reload (code=exited, status=0/SUCCESS) Main PID: 2400 (nginx) Tasks: 9 (limit: 9830) Memory: 24.5M CGroup: /system.slice/nginx.service ├─2400 "nginx: master process /usr/sbin/nginx -g daemon on; master_process on;" ├─2439 "nginx: worker process" ├─2440 "nginx: worker process" ├─2441 "nginx: worker process" ├─2442 "nginx: worker process" ├─2443 "nginx: worker process" ├─2444 "nginx: worker process" ├─2445 "nginx: worker process" └─2446 "nginx: worker process"
Sep 04 21:11:21 dev systemd[1]: Starting nginx.service - A high performance web server and a reverse proxy server... Sep 04 21:11:21 dev systemd[1]: Started nginx.service - A high performance web server and a reverse proxy server. Sep 04 21:11:23 dev systemd[1]: nginx.service: Failed to get CPU usage: No such file or directory Sep 04 21:11:23 dev systemd[1]: Reloading nginx.service - A high performance web server and a reverse proxy server... Sep 04 21:11:23 dev nginx[2437]: 2026/09/04 21:11:23 [notice] 2437#2437: signal process started Sep 04 21:11:23 dev systemd[1]: Reloaded nginx.service - A high performance web server and a reverse proxy server. Sep 04 21:12:32 dev systemd[1]: nginx.service: Failed to get CPU usage: No such file or directory chert@dev:~$
And nginx responds to web traffic normally:
Expand to see the curl http://127.0.0.1 output.
chert@dev:~$ curl http://127.0.0.1
<!DOCTYPE html> <html> <head> <title>Welcome to nginx!</title> <style> html { color-scheme: light dark; } body { width: 35em; margin: 0 auto; font-family: Tahoma, Verdana, Arial, sans-serif; } </style> </head> <body> <h1>Welcome to nginx!</h1> <p>If you see this page, the nginx web server is successfully installed and working. Further configuration is required.</p> <p>For online documentation and support please refer to <a href="http://nginx.org/">nginx.org</a>.<br/> Commercial support is available at <a href="http://nginx.com/">nginx.com</a>.</p> <p><em>Thank you for using nginx.</em></p> </body> </html> chert@dev:~$A number of other popular services, including Apache, PostgreSQL, MariaDB, Redis, and Docker, have been tested to work under systemd in gVisor. These services are now a part of gVisor’s integration test suite.
gVisor’s ability to run full-system containers opens up an interesting extension to an earlier post, Multi-Agent gVisor Isolation (MAGI). MAGI demoed sandboxing AI agents in gVisor with OpenClaw.
By inserting a small MCP server between OpenClaw and a GNOME container like the one we created earlier, we can give our OpenClaw agents the ability to use a full Linux desktop as a tool, with a virtual mouse and keyboard as input devices.
First, start by following the “Basic machine setup” section of the MAGI post, creating a GPU VM instance and installing Docker, gVisor, and the NVIDIA drivers. There a
正文由 探How 从来源站点 RSS 同步,内容未经改写;遇到排版缺失或需要图片、视频时请以原文为准。