Skip to main content

Deploy with Docker and LXC

Running Steam Headless inside a Linux Container (LXC) via Docker Compose provides near-bare-metal gaming and streaming performance without the virtualisation overhead of a full virtual machine. This deployment pattern is ideal for Proxmox Virtual Environment (PVE) and other LXC/Incus hosts.

Before following this guide, ensure your host system and LXC container have been configured with hardware passthrough following the Prepare a Proxmox VE Host guide.


Why Use Docker Inside LXC?​

While LXC excels at managing system resources and hardware passthrough, application containers (such as Steam Headless) benefit from Docker's declarative configuration, immutable image layers, and simple updates:

  • Effortless Updates: Upgrading Steam Headless requires only docker compose pull && docker compose up -d, replacing the container rootfs without rebuilding the LXC container.
  • Reproducible Configuration: All capabilities, devices, memory allocations, and network configurations are version-controlled in a single docker-compose.yml file.
  • Multi-Container Support: Running multiple concurrent gaming sessions on distinct LAN IP addresses is straightforward using Docker Compose service definitions.

Networking Strategy: Macvlan vs Host Networking​

Steam Headless supports two primary networking modes when running inside an LXC container:

  1. Macvlan Networking (Documented below): Connects each Steam Headless container directly to your physical network using the LXC container's parent interface (eth0). Each container receives a distinct MAC address and a dedicated local IP address, eliminating port conflicts and allowing multiple containers to run standard Sunshine and web ports.
  2. Host Networking: Shares the LXC container's network stack directly. While simpler, host networking restricts you to a single Steam Headless container per LXC because Sunshine (UDP 47998-48000) and SHUI (TCP/UDP 8483) cannot share ports on the same IP address.

This guide configures Macvlan networking by default.


Step 1: Access the LXC Container​

Log in to your LXC container shell. On Proxmox VE, you can enter the container directly from the host terminal:

pct enter 500

(Replace 500 with your LXC container ID, or connect directly via SSH).


Step 2: Verify Hardware Passthrough​

Before installing Docker, confirm that your graphics card and virtual input device nodes are accessible inside the LXC container:

ls -l /dev/dri /dev/uinput /dev/uhid /dev/fuse

Ensure all paths exist:

  • /dev/dri/renderD128 (or your platform's render node)
  • /dev/uinput
  • /dev/uhid
  • /dev/fuse

If any device node is missing, review Section 2.3 of the Prepare a Proxmox VE Host guide.


Step 3: Install Docker Engine​

Inside the Ubuntu 24.04 LTS LXC container, install Docker Engine and the Docker Compose plugin from Docker's official repository:

apt-get update
apt-get install -y ca-certificates curl gnupg

install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
chmod a+r /etc/apt/keyrings/docker.asc

echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \
$(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
tee /etc/apt/sources.list.d/docker.list > /dev/null

apt-get update
apt-get install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

systemctl enable --now docker

Verify that the Docker daemon is active:

docker ps

Optional: Enable NVIDIA inside the LXC container​

Skip this section for Intel or AMD graphics. For NVIDIA, first complete the Proxmox NVIDIA device passthrough. Run the installation commands below as root inside the Ubuntu LXC container.

Install matching NVIDIA userspace libraries​

Download the helper inside your Ubuntu 24.04 (amd64) LXC container. This setup requires an NVIDIA R590 or newer driver on the Proxmox host.

apt-get update
apt-get install -y ca-certificates curl
curl -fsSL https://steamheadless.com/scripts/install-nvidia-lxc-userspace \
-o /usr/local/sbin/install-nvidia-lxc-userspace
chmod 0755 /usr/local/sbin/install-nvidia-lxc-userspace

Run the first installation in your terminal so you can follow its progress. Stop Docker first; this interrupts any containers already running in this LXC. Continue only after the helper finishes successfully and nvidia-smi lists your GPU:

systemctl stop docker.socket docker.service
/usr/local/sbin/install-nvidia-lxc-userspace && nvidia-smi

Create a boot service to synchronise the libraries before Docker starts:

cat > /etc/systemd/system/install-nvidia-lxc-userspace.service <<'EOF'
[Unit]
Description=Match NVIDIA userspace to the loaded Proxmox driver
Wants=network-online.target
After=network-online.target
Before=docker.service

[Service]
Type=oneshot
ExecStart=/usr/local/sbin/install-nvidia-lxc-userspace
RemainAfterExit=yes
TimeoutStartSec=15min

[Install]
WantedBy=multi-user.target
EOF

mkdir -p /etc/systemd/system/docker.service.d
cat > /etc/systemd/system/docker.service.d/nvidia-userspace.conf <<'EOF'
[Unit]
Requires=install-nvidia-lxc-userspace.service
After=install-nvidia-lxc-userspace.service
EOF

Enable the service for future starts:

systemctl daemon-reload
systemctl enable install-nvidia-lxc-userspace.service

The service prepares NVIDIA libraries before Docker starts. If it fails, Docker stays stopped; check journalctl -u install-nvidia-lxc-userspace.service for the cause.

Install and configure the NVIDIA Container Toolkit​

Add the official NVIDIA Container Toolkit repository and install the toolkit:

apt-get install -y curl gnupg
curl -fsSL https://nvidia.github.io/libnvidia-container/gpgkey | \
gpg --dearmor -o /usr/share/keyrings/nvidia-container-toolkit-keyring.gpg
curl -fsSL https://nvidia.github.io/libnvidia-container/stable/deb/nvidia-container-toolkit.list | \
sed 's#deb https://#deb [signed-by=/usr/share/keyrings/nvidia-container-toolkit-keyring.gpg] https://#g' | \
tee /etc/apt/sources.list.d/nvidia-container-toolkit.list
apt-get update
apt-get install -y nvidia-container-toolkit

nvidia-ctk runtime configure --runtime=docker
systemctl restart docker

Verify that Docker can access the GPU:

docker run --rm --runtime=nvidia --gpus all \
--security-opt apparmor=unconfined \
-e NVIDIA_DRIVER_CAPABILITIES=all \
--entrypoint nvidia-smi josh5/steam-headless:2

The command must list the same GPU and driver version. In Step 4, use the NVIDIA Compose example, including runtime: nvidia and the NVIDIA environment settings from GPU options.


Step 4: Configure Docker Compose​

Create a dedicated directory for your Steam Headless deployment:

mkdir -p /opt/steam-headless
cd /opt/steam-headless
nano docker-compose.yml

Consult the Deploy with Docker Compose guide to select and copy your preferred docker-compose.yml template:

  • Macvlan Networking: Recommended for LXC containers. Assigns dedicated LAN IP addresses directly on the LXC container's parent interface (parent: eth0).
  • Host Networking: Simplest single-instance setup, sharing the LXC container's network stack directly.
  • Multi-Container Deployment: Run multiple independent gaming sessions concurrently inside the same LXC container using Macvlan.
LXC Compose Considerations

When copying the Compose template, verify that:

  • Devices: The devices: block includes the device nodes passed through to your LXC container (/dev/dri/renderD128, /dev/fuse, /dev/uinput, and /dev/uhid).
  • Macvlan Parent: The driver_opts.parent setting is set to eth0 (the primary network interface inside the LXC container).
  • Game Storage: If you passed through a host game directory or dedicated storage volume as mp0 in /etc/pve/lxc/500.conf, uncomment or add - /mnt/games:/mnt/games under volumes.

Step 5: Start the Container​

Start Steam Headless in detached mode:

docker compose up -d

Follow the startup journal to monitor the initial desktop configuration:

docker compose logs -f

Startup is complete when the log displays systemd[1]: Startup finished in ... and reports that Sunshine and Steam Headless UI have started.


Step 6: Connect to Steam Headless​

Once the container is running:

  1. Browser Access (Steam Headless UI): Open your browser and navigate to:

    https://<CONTAINER_IP>:8483

    Accept the self-signed TLS certificate and log in with the default credentials (steamheadless / steamheadless). From here, you can stream the desktop directly in your browser, configure displays, and manage system services.

  2. Moonlight Streaming (Sunshine): Open Moonlight on your client device (PC, TV, phone, or handheld). Moonlight will detect the Steam Headless host automatically via LAN discovery. Click the host and enter the pairing PIN in the Steam Headless UI under the Sunshine tab.


Step 7: Upgrading the Container​

To upgrade Steam Headless when a new image release is published, navigate to your deployment directory and pull the latest image:

cd /opt/steam-headless
docker compose pull
docker compose up -d

Docker Compose will recreate the container using the newly pulled image while preserving your user settings, Steam library, and pairing credentials on the persistent volumes.