DEV Community

Cover image for Install Steam in a Distrobox Container With x86-64-v3 Power Boost!
Archer Allstars
Archer Allstars

Posted on

Install Steam in a Distrobox Container With x86-64-v3 Power Boost!

Like always, I prefer to install any app in a manageable way, i.e., layer on the base system without altering the base in any way or leaving a lot of residue upon uninstallation.

Moreover, you can choose to use any images you want regardless of your base system. For example, you can use the official CachyOS image that provides x86-64-v3 optimized packages, hence improving gaming performance.


1. Installing Distrobox and Podman

The command will differ based on your specific package manager. Refer to your distro's docs. For example, on Arch based distros:

sudo pacman -S distrobox podman
Enter fullscreen mode Exit fullscreen mode

2. Configure Distrobox to use Podman

echo 'container_manager="podman"' > ~/.config/distrobox/distrobox.conf
Enter fullscreen mode Exit fullscreen mode

3. Create a container

distrobox-create -i docker.io/cachyos/cachyos-v3:latest -n games-dbx -H ~/distrobox/games-dbx --additional-flags "--dns=none" --volume /run/dbus/system_bus_socket:/run/dbus/system_bus_socket
Enter fullscreen mode Exit fullscreen mode

I use the --dns=none flag because I want to go as light as possible by not using an init container (a container with its own systemd). Without this flag, Steam will try to find systemd-resolved, of which doesn't exist obviously, and won't be able to launch successfully.

Without systemd inside the container, Steam will always show UTC time instead of your local time in Big Picture Mode, see Steam issue #10057.

Note: For NVIDIA users, in order to use the GPU inside the container, you need to add --nvidia flag to the distrobox-create command. See more here.


4. Enable x86-64-v3 packages

Once the container is created, enter the container and enable x86-64-v3 packages:

sudo pacman -Syu
Enter fullscreen mode Exit fullscreen mode
sudo pacman -Qqn | sudo pacman -S -
Enter fullscreen mode Exit fullscreen mode

5. Generating the container's locales

First, install nano to be able to edit /etc/locale.gen:

sudo pacman -S nano
Enter fullscreen mode Exit fullscreen mode

Then, editing /etc/locale.gen:

sudo nano /etc/locale.gen
Enter fullscreen mode Exit fullscreen mode

Uncomment (removing #) from en_US.UTF-8 UTF-8 line. Also, if your local language is differ, uncomment your local language too. For example:

en_US.UTF-8 UTF-8
th_TH.UTF-8 UTF-8
Enter fullscreen mode Exit fullscreen mode

Lastly, generating locales:

sudo locale-gen
Enter fullscreen mode Exit fullscreen mode

6. Install Steam!

sudo pacman -S steam
Enter fullscreen mode Exit fullscreen mode

If you're asked during the installation,...

About the font, I use Noto font.

About which Vulkan to use, use your vendor's Vulkan. It should be obvious enough, for example, vulkan-intel (or lib32-vulkan-intel).

Please use everything from CachyOS repository if being asked.


7. Export Steam inside the container to the host

Run this inside the container:

distrobox-export -a steam
Enter fullscreen mode Exit fullscreen mode

With this, you will be able to launch Steam on the host, i.e., with Steam icon on the host.


8. Auto-update the container, zero maintenance time!

Create a systemd service file:

nano ~/.config/systemd/user/dbx-upgrade.service
Enter fullscreen mode Exit fullscreen mode

Inside the service file:

[Unit]
Description=Upgrade all Distrobox containers
RequiresMountsFor=/run/user/1000/containers
StartLimitBurst=3
StartLimitIntervalSec=600

[Service]
Type=exec
ExecStart=sh -c "distrobox-upgrade --all"
Restart=on-failure
RestartSec=60
Enter fullscreen mode Exit fullscreen mode

Create a systemd timer file:

nano ~/.config/systemd/user/dbx-upgrade.timer
Enter fullscreen mode Exit fullscreen mode

Inside the timer file:

[Unit]
Description=Start Distrobox containers upgrade service with some delay.

[Timer]
OnStartupSec=30
RandomizedDelaySec=15
Persistent=true

[Install]
WantedBy=timers.target
Enter fullscreen mode Exit fullscreen mode

Reload and enable the timer:

systemctl --user daemon-reload && systemctl --user enable dbx-upgrade.timer
Enter fullscreen mode Exit fullscreen mode

BONUS: Increase vm.max_map_count

According to Arch Wiki, it's recommended to increase the vm.max_map_count.

This one has to be done on the host and the container will follow automatically. The procedure should be the same across all distros.

Create a sysctl rule:

sudo nano /etc/sysctl.d/99-gamecompatibility.conf
Enter fullscreen mode Exit fullscreen mode

Add vm.max_map_count = 2147483642 in the file.

Then, apply the change immediately with:

sudo sysctl --system
Enter fullscreen mode Exit fullscreen mode

With this, you should be able to run Steam inside a container. Enjoy!


Cover Photo by Igor Saikin on Unsplash

Top comments (0)