Skip to content

Containers

Gudule Lapointe edited this page Dec 1, 2026 · 3 revisions

Run a grid in a container

This guide installs an OpenSimulator grid in a container, with the w4os tools, and a website in another container beside it. It works with Podman and with Docker. The steps are the ones tested on 2026-12-01; the outputs are real, trimmed.

How it fits together

  • The grid container is a small server: systemd runs Robust, the simulators, MariaDB, PHP-FPM and Caddy. You install it with kickstart.sh, exactly as on a VPS, and you update it with apt.
  • The website container runs the w4os site (or any site with the w4os plugin). It talks to the grid through the engine API, with a key.
  • Both share one network namespace (a Podman pod, or --network container: with Docker). The engine API listens on 127.0.0.1, so it is never exposed outside.
  • The data lives in named volumes. You can delete and recreate the containers: the grid comes back.
             viewers                         browsers
   8002/tcp  9000/tcp  9001/udp              80, 443
       │        │         │                     │
┌──────┴────────┴─────────┴─────────────────────┴──────────────────┐
│ pod "mygrid"                                                       │
│  ┌──────────────── grid container ─────────────────┐              │
│  │ Robust 8002  simulator 9000 / 9001  MariaDB     │              │
│  │ Caddy: /helpers here, the rest ──────────────────┼──┐           │
│  │ engine API on 127.0.0.1:8005 ◄───────────────────┼──┼──┐        │
│  └──────────────────────────────────────────────────┘  │  │        │
│  ┌──────────────── site container ─────────────────┐   │  │        │
│  │ Caddy on 127.0.0.1:8090 ◄─────────────────────────────┘  │        │
│  │ w4os site (Grav), engine: remote ────────────────────────┘        │
│  └──────────────────────────────────────────────────┘              │
└────────────────────────────────────────────────────────────────────┘

What you need

  • A Linux host with Podman 4.9 or newer, or Docker. Run the commands as root (rootful containers).
  • 2 GB of free memory for a grid with one region, and 4 GB of disk.
  • A host name for the grid that points to the host, for example grid.example.org. Viewers use it.
  • These ports open on the host and at your provider: 8002/tcp (login), 9000/tcp and 9001/udp (the first region), 80/tcp and 443/tcp (the website and the helpers).

In this guide the grid is My Grid, its short name (nick) my_grid, its address grid.example.org. Change them.

1. Build the base image

The image is Debian with systemd. Nothing of OpenSimulator is in it: kickstart installs that inside the container.

Containerfile:

FROM docker.io/library/debian:13
RUN apt-get update \
 && apt-get install -y --no-install-recommends systemd systemd-sysv dbus curl ca-certificates \
 && rm -rf /var/lib/apt/lists/* /usr/sbin/policy-rc.d
STOPSIGNAL SIGRTMIN+3
CMD ["/sbin/init"]

Removing policy-rc.d lets the packages start their services, as on a server.

podman build -t localhost/opensim-host:debian13 .

2. Create the pod and the grid container

The ports are those of the grid: published once, here. The defaults are 8002 for Robust, 9000 and 9001/udp for the first simulator. A second region needs 9002/udp; a second simulator 9010/tcp and 9011/udp. Publish them now, or recreate the pod later (step 8).

podman pod create --name mygrid --hostname mygrid \
  -p 8002:8002/tcp -p 9000:9000/tcp -p 9001:9001/udp \
  -p 80:80/tcp -p 443:443/tcp

podman run -d --pod mygrid --name mygrid-grid \
  -v mygrid-etc:/etc/opensim \
  -v mygrid-data:/var/lib/opensim \
  -v mygrid-logs:/var/log/opensim \
  -v mygrid-db:/var/lib/mysql \
  -v mygrid-w4os:/etc/w4os \
  -v /var/backups/opensim/mygrid:/var/backups/opensim \
  --stop-timeout 120 \
  localhost/opensim-host:debian13

Create the backup folder first (mkdir -p /var/backups/opensim/mygrid). On a host with SELinux (Fedora, RHEL), add :Z to that folder: -v /var/backups/opensim/mygrid:/var/backups/opensim:Z.

Check that systemd runs:

podman exec mygrid-grid systemctl is-system-running
running

3. Install the grid

Open a shell in the container, then run kickstart as on a server:

podman exec -it mygrid-grid bash
cd /root
curl -fsSL -O https://raw.githubusercontent.com/way4os/w4os-cli/charm-dev/kickstart.sh
chmod +x kickstart.sh
./kickstart.sh --unstable --setup

--unstable gives the beta. The install takes about ten minutes:

w4os installer
 System: Debian GNU/Linux 13 (trixie), 8 GB RAM, 252 GB free
? Install w4os-engine? [Y/n] y
 Tools (22)
 Database server (71)
 Packages (257)
 .NET 8 runtime
OpenSim setup
  1) New grid

Choose New grid. In the Grid form:

  • Address: the host name of the grid, grid.example.org. Not the name of the container.
  • Ports: keep 8002 8003, the ones published.
  • Owner, Password, Email: the first avatar, owner of the regions.

At Website address, give https://grid.example.org/. The review then shows what will be made:

Review
  Grid
    1) Name                 My Grid (my_grid)
    2) Login                grid.example.org:8002
  Simulator
    7) Name                 Welcome (my_grid.welcome)
    8) Ports                9000 http, 9001 udp, 9004 console
  Folders
   25) Config files         /etc/opensim
   26) State                /var/lib/opensim
   28) Logs                 /var/log/opensim
   30) Backups              /var/backups/opensim
Edit [1-31, Enter to continue]:

The folders are the volumes of step 2. Press Enter, then Start. The setup makes the databases, starts the grid, makes the owner and the region. Its last step, the website, has no web server here: choose Skip. The website has its own container (step 6).

Website failed
web: [ERROR] no Caddy nor Apache on this machine: the Quick Start website is put beside a site of one of them
  1) Retry
  2) Skip
Choose [1-2]: 2
Grid       My Grid (my_grid)
Login      http://grid.example.org:8002
Website    not installed: a rerun installs it

The simulator reaches Robust inside the container (PrivURL = "http://127.0.0.1"), and the region announces the address of the grid (ExternalHostName = grid.example.org): viewers reach it through the published ports.

4. Check the grid

opensim status
INSTANCE         TYPE     PID    USER     %CPU  %MEM  RSS     AVATARS
my_grid          robust   33848  opensim  21.5  1.7   140736  0
my_grid.welcome  opensim  33891  opensim  29.2  2.0   161516  0
2 up - 0 avatars - cpu 50.5% - mem 3.7% - rss 302276

From another computer:

curl http://grid.example.org:8002/get_grid_info
<gridinfo><platform>OpenSim</platform><login>http://grid.example.org:8002/</login><gridname>My Grid</gridname>...

Then sign in with a viewer: login URI http://grid.example.org:8002/, the owner avatar.

5. The web front of the grid

The helpers (search, profiles, splash page, economy) and the engine API need the files of the grid: they run in the grid container, with Caddy. Still in the grid container:

apt-get install -y caddy
printf 'import sites/*\n' > /etc/caddy/Caddyfile
mkdir -p /etc/caddy/sites
systemctl restart caddy

# The engine API, on 127.0.0.1:8005, run as the account of the grid
opensim web my_grid api caddy --install

# The helpers, and the rest of the address to the website container
opensim web my_grid snippet caddy | grep -v '^#' > /etc/caddy/my_grid-helpers.caddy
cat > /etc/caddy/sites/my_grid-front.caddyfile <<'EOF'
grid.example.org {
	import /etc/caddy/my_grid-helpers.caddy
	handle {
		reverse_proxy 127.0.0.1:8090
	}
}
EOF
systemctl reload caddy
✓ Engine API: http://127.0.0.1:8005/api

Caddy gets the HTTPS certificate of grid.example.org by itself, through ports 80 and 443.

Make a key for the website, and keep it:

su -s /bin/bash opensim -c 'opensim api-key create w4os-site'
osk_...
api-key: key 62f4d50f (w4os-site) made; it is shown once, keep it now

Leave the grid container (exit).

6. The website container

The w4os site, from the same base image, in the same pod:

podman run -d --pod mygrid --name mygrid-site \
  -v mygrid-www:/var/lib/w4os \
  localhost/opensim-host:debian13
podman exec -it mygrid-site bash

In it:

mkdir -p /etc/apt/keyrings
curl -fsSL https://apt.magiiic.com/magiiic-packaging.asc -o /etc/apt/keyrings/magiiic-packaging.asc
echo "deb [signed-by=/etc/apt/keyrings/magiiic-packaging.asc] https://apt.magiiic.com charm stable unstable" \
  > /etc/apt/sources.list.d/magiiic.list
apt-get update
apt-get install -y w4os-site caddy php-fpm

# Two Caddy servers share the network of the pod: this one keeps its admin port apart
printf '{\n\tadmin localhost:2020\n}\nimport sites/*\n' > /etc/caddy/Caddyfile
mkdir -p /etc/caddy/sites
cat > /etc/caddy/sites/w4os-site.caddyfile <<'EOF'
http://:8090 {
	encode gzip
	import /usr/share/w4os-site/web/grav.caddy /var/lib/w4os/www unix//run/php/php8.4-fpm.sock /index.php
}
EOF
systemctl restart caddy php8.4-fpm

w4os-site setup --api http://127.0.0.1:8005/api --url https://grid.example.org/helpers --key osk_... --grid my_grid
w4os-site status
w4os-site: connected to My Grid (http://127.0.0.1:8005/api)
key:     set
api:     answers
blocks:  answer

Open https://grid.example.org/: the home page, Create My Avatar, Login, the search.

WordPress, or a site elsewhere

A WordPress site with the w4os plugin works the same way: engine: remote, the API address and the key. In the same pod, the API is http://127.0.0.1:8005/api. On another machine, the API must be reached over a private network (a VPN such as WireGuard): publish it only on that network's address, never on the public one.

7. Volumes and backups

Volume Path in the container What it holds
mygrid-etc /etc/opensim the config of the grid, its simulators and regions
mygrid-data /var/lib/opensim the state and data files (assets of the grid, map tiles)
mygrid-logs /var/log/opensim the logs
mygrid-db /var/lib/mysql the databases (accounts, inventories, regions)
mygrid-w4os /etc/w4os the database accounts of the tools, the settings of w4os
host folder /var/backups/opensim the backups
mygrid-www /var/lib/w4os (site) the website: pages, settings, accounts

The cache (/var/cache/opensim) and the packages are not kept: kickstart puts them back.

A backup of the grid (config, data, databases), in the host folder:

podman exec mygrid-grid su -s /bin/bash opensim -c 'opensim backup my_grid'
backing up grid my_grid...
  database my_grid_robust
  database my_grid_welcome
/var/backups/opensim/my_grid/my_grid-20261201-174632.tar.gz

Every night at 03:30:

podman exec mygrid-grid systemctl enable --now opensim-backup.timer

8. Stop, update, recreate

Stop and start: the regions shut down cleanly (about 10 seconds), and the grid starts again with the container.

podman pod stop mygrid
podman pod start mygrid

Update the packages, inside the grid container:

podman exec mygrid-grid sh -c 'apt-get update && apt-get upgrade -y && systemctl restart opensim'

Recreate the grid container (a new base image, or other ports): the volumes keep everything. Remove it, run the command of step 2 again, then:

podman exec -it mygrid-grid bash
cd /root && curl -fsSL -O https://raw.githubusercontent.com/way4os/w4os-cli/charm-dev/kickstart.sh && chmod +x kickstart.sh
./kickstart.sh --unstable --yes
systemctl restart opensim
opensim status
✓ Packages (257)
✓ Modules of the grids (1)
✓ .NET 8 runtime
✓ Installed
...
2 up - 0 avatars - cpu 64.3% - mem 3.9% - rss 316024

Kickstart puts back the module packages the grids use (here the 3D map). Then step 5 again, without the key. Kickstart finds the grid in the volumes; the avatars, regions and settings are there. To change the ports, the pod itself is recreated (podman pod rm -f mygrid, then step 2 and the site of step 6).

Docker

The same steps, with these differences:

  • Build: docker build -t opensim-host:debian13 .
  • systemd needs the cgroups: add --cgroupns=host -v /sys/fs/cgroup:/sys/fs/cgroup:rw --tmpfs /run --tmpfs /run/lock --tmpfs /tmp to both docker run.
  • No pods: the ports go on the grid container, and the site joins its network:
docker run -d --name mygrid-grid --hostname mygrid \
  --cgroupns=host -v /sys/fs/cgroup:/sys/fs/cgroup:rw --tmpfs /run --tmpfs /run/lock --tmpfs /tmp \
  -p 8002:8002/tcp -p 9000:9000/tcp -p 9001:9001/udp -p 80:80/tcp -p 443:443/tcp \
  -v mygrid-etc:/etc/opensim -v mygrid-data:/var/lib/opensim -v mygrid-logs:/var/log/opensim \
  -v mygrid-db:/var/lib/mysql -v mygrid-w4os:/etc/w4os -v /var/backups/opensim/mygrid:/var/backups/opensim \
  --stop-timeout 120 opensim-host:debian13

docker run -d --name mygrid-site --network container:mygrid-grid \
  --cgroupns=host -v /sys/fs/cgroup:/sys/fs/cgroup:rw --tmpfs /run --tmpfs /run/lock --tmpfs /tmp \
  -v mygrid-www:/var/lib/w4os opensim-host:debian13
  • docker exec instead of podman exec; docker restart mygrid-grid instead of podman pod stop|start.
  • When the grid container is recreated, recreate the site container too: it was attached to the network of the old one.

Known limits

  • Needs w4os-engine and kickstart from 2026-12-02 or later. With older packages, the setup stops with "the owner of its estate ... is not an account of its grid", and viewers are sent to the address of the container.
  • After recreating the grid container, opensim.service is restarted by hand (step 8).
  • Tested with rootful Podman 5.7 (Ubuntu 26.04) and Docker 29 (Ubuntu 24.04), Debian 13 in the container, on a local network: the grid at an IP address, the web front on plain HTTP. HTTPS with a public name (step 5) and rootless containers are not tested yet.
  • Simulators on other machines, joining this grid, need the private port 8003: not covered here.
  • One grid per pod. A second grid takes other ports (8102, 9100...), chosen in its setup and published by its own pod.

Clone this wiki locally