Quick
Ephemeral firefox container.
lxc init images:debian/10 -e temp
lxc config device add temp X11 disk source=/tmp/.X11-unix path=/tmp/.X11-unix
lxc config device add temp pulse disk source=/tmp/pulse-socket path=/tmp/pulse-socket
lxc start temp
lxc exec temp -- /bin/bash -c "while ! ip a s dev eth0 | grep 'inet ' ; do sleep 1 ; done ; apt install -y pulseaudio firefox-esr"
lxc exec temp -- /bin/bash -c "echo 'default-server = unix:/tmp/pulse-socket' >> /etc/pulse/client.conf"
lxc exec temp -- useradd -m user
xhost si:localuser:#1001000
lxc exec temp -- runuser user -c "DISPLAY=:0 firefox https://addons.mozilla.org/firefox/downloads/file/3768975/ublock_origin-1.35.2-an+fx.xpi &"
lxc stop temp
xhost -si:localuser:#1001000
Configure PulseAudio
Add to /etc/pulse/default.pa
load-module module-native-protocol-unix auth-anonymous=1 socket=/tmp/pulse-socket
Reload PulseAudio.
pulseaudio -k
pulseaudio --start
Maybe you need this too.
rm -rf /tmp/pulse* ~/.pulse* ~/.config/pulse
Create the container
lxc init ubuntu:18.04/amd64 xorg
lxc config device add xorg x11 disk source=/tmp/.X11-unix path=/tmp/.X11-unix
lxc config device add xorg pulse disk source=/tmp/pulse-socket path=/tmp/pulse-socket
lxc start xorg
lxc exec xorg -- /bin/bash
Configure
Then install pulseaudio
and a GUI program and export the location of PulseAudio socket.
apt install -y pulseaudio firefox
echo "default-server = unix:/tmp/pulse-socket" >> /etc/pulse/client.conf
Connect to container
SSH
ssh -X -l user "$(lxc list | grep xorg | awk '{print $6}')" firefox
LXD. user
may be ubuntu
, if not useradd -m user
xhost si:localuser:#1001000
lxc exec xorg -- runuser user -c "DISPLAY=:0 firefox &"