Create container:
[iaroki@fedora ~]$ lxc launch images:debian/stretch chrome
Install needed tools:
[iaroki@fedora ~]$ lxc exec chrome bash root@chrome:~# adduser iaroki root@chrome:~# apt update root@chrome:~# apt install x11-apps mesa-utils alsa-utils
Map UID and GID ramges:
[iaroki@fedora ~]$ echo "root:1000:1" | sudo tee -a /etc/subuid /etc/subgid
Set UID/GUID ranges for container:
[iaroki@fedora ~]$ lxc config set chrome raw.idmap "both $UID 1000" [iaroki@fedora ~]$ lxc restart chrome
Mount X11 socket and .Xauthority file:
[iaroki@fedora ~]$ lxc config device add chrome X0 disk path=/tmp/.X11-unix/X0 source=/tmp/.X11-unix/X0 [iaroki@fedora ~]$ lxc config device add chrome Xauthority disk path=/home/iaroki/.Xauthority source=${XAUTHORITY}
Passthrough GPU device:
[iaroki@fedora ~]$ lxc config device add chrome GPU gpu [iaroki@fedora ~]$ lxc config device set GPU uid 1000 [iaroki@fedora ~]$ lxc config device set GPU gid 1000
Check results with:
[iaroki@fedora ~]$ lxc exec chrome -- sudo --login --user iaroki iaroki@chrome:~$ export DISPLAY=:0 iaroki@chrome:~$ echo "export DISPLAY=:0" >> ~/.profile iaroki@chrome:~$ glxgears
Now we can install and run chromium browser inside:
[iaroki@fedora ~]$ lxc exec chrome -- sudo --login --user iaroki iaroki@chrome:~$ sudo apt install chromium iaroki@chrome:~$ chromium
Reblogged this on SourceContribute and commented:
Instructions on how to use LXC (Linux Containers) to run GUI applications within a container. The example shows how to run chromium with X11 and GPU-accelerated.
LikeLike
I have been following these examples, but where I get to the Passthrough GPU device: part
lxc config device set chrome uid 1000
I get
error: wrong number of subcommand arguments
On Fedora 27
LikeLike
Answering my own question … đŸ™‚
It should be
[iaroki@fedora ~]$ lxc config device add chrome GPU gpu
[iaroki@fedora ~]$ lxc config device set *GPU* uid 1000
[iaroki@fedora ~]$ lxc config device set *GPU* gid 1000
minus the asterisks, there for attention.
Hope that helps someone
LikeLiked by 1 person
Yes, of course it must be the name of our gpu. Thanks for pointing on that and leaving the commentary. Corrected it now.
LikeLike