SoftwareContainer Plugin Example

Learn how to integrate Software Containers with the Application Manager.

Introduction

This example shows how to integrate Pelagicore's SoftwareContainers with the Application Manager.

Note: As a prerequisite, familiarize yourself with Containers beforehand.

In softwarecontainer.cpp, parts of the container's configuration is hardcoded; all of the capability definition is in the JSON manifest file located in service-manifest.d/io.qt.AppliciationManager.Application/.

The Wayland/OpenGL passthrough is tested against Intel GPUs and VMWare's virtual GPU.

Run the SoftwareContainer Agent

To run the softwarecontainer-agent, you must start it as root. By default, this agent registers itself on the system D-Bus. So, you need to have a policy file in place, to allow the agent to register itself on the system-bus.

If you want to run the agent on the session bus instead, via the --session-bus parameter, then you have to add the following lines to one of your config.yaml files:

containers:
  softwarecontainer:
    dbus: 'session'

It's mandatory to pass the service manifest directory that comes with the plugin via -m. Otherwise, the container setup fails due to the missing io.qt.ApplicationManager.Application capability.

Make sure that the agent has access to the same session bus that the application manager uses, if you intend on forwarding this bus. If the agent is run as root, but the application manager isn't, this can be tricky -- since the default session bus policy in most Linux distros disallows root to access user session busses. However, you can workaround this issue by adding an <allow user="root"/> policy within the <policy context="default"> element in /etc/dbus-1/session.conf.

Additionally, make sure to tell the agent about your environment, when running it via sudo:

sudo XDG_RUNTIME_DIR=$XDG_RUNTIME_DIR
DBUS_SESSION_BUS_ADDRESS=$DBUS_SESSION_BUS_ADDRESS softwarecontainer-agent -m
/path/to/application-manager/examples/softwarecontainer-plugin/service-manifest.d/

On the Application Manager side, you need to activate the plugin by adding a line similar to the one shown below, to one of your config.yaml files:

plugins:
   container: [ "/path/to/libsoftwarecontainer-plugin.so" ]

To actually run applications within software containers, you have to add a container selection configuration. For more information, see Container Selection Configuration.

To simplify developing on the desktop, normally, you want your $HOME directory mounted into the container in read-only mode. This way, you don't have to install your application manager into /usr/ after every build. This behavior only works, given that your build directory is located somewhere in $HOME, otherwise the container won't see the appman-launcher-qml binary. This behavior is not enabled by default; but you can activate it with the following lines in one of your config.yaml files:

containers:
  softwarecontainer:
    bindMountHome: yes

Example project @ code.qt.io