No Sound with graphics-accelerated GUI apps in LXD containers


I want to run FireFox in a LXD container. I followed this wonderful HOWTO: How to run graphics-accelerated GUI apps in LXD containers on your Ubuntu desktop to a “T” (or I believe so) but can’t seem to get audio to work. In fact, I run into this little error:

speaker-test -Dpulse -c6 -twav

speaker-test 1.1.3

    Playback device is pulse
    Stream parameters are 48000Hz, S16_LE, 6 channels
    WAV file(s)
    ALSA lib pulse.c:243:(pulse_connect) PulseAudio: Unable to connect: Connection refused

    Playback open error: -111,Connection refused

Trying some of the troubleshooting tips I get the following on the guest:

ubuntu@Firefox:~$ sudo lsof -i:4713


ubuntu@Firefox:~$ telnet 4713

(I escaped out because it wasn’t doing anything).

Trying to use youtube on firefox within the container produced this error:

ubuntu@Firefox:~$ firefox
[Child 3322, MediaDecoderStateMachine #1] WARNING: 7fea18ef8600 OpenCubeb() failed to init cubeb: file /build/firefox-CTCO4D/firefox-73.0.1+build1/dom/media/AudioStream.cpp, line 328
[Child 3322, MediaDecoderStateMachine #1] WARNING: Decoder=7fea17fda400 [OnMediaSinkAudioError]: file /build/firefox-CTCO4D/firefox-73.0.1+build1/dom/media/MediaDecoderStateMachine.cpp, line 3710
IPDL protocol error: Handler returned error code!

On the host it seems like PulseAudio is listening:

xxxx@KubuntuOptiPlex3040:~$ sudo lsof -i:4713
[sudo] password for xxxx: 
pulseaudi 4501 xxxx   35u  IPv6 172010      0t0  TCP *:4713 (LISTEN)
pulseaudi 4501 xxxx   36u  IPv4 172011      0t0  TCP *:4713 (LISTEN)

Any suggestions? Thank you!

EDIT: Forgot to add some pertinent info :grimacing:

description: Audio device
product: 100 Series/C230 Series Chipset Family HD Audio Controller
vendor: Intel Corporation
physical id: 1f.3
bus info: pci@0000:00:1f.3
version: 31
width: 64 bits
clock: 33MHz
capabilities: pm msi bus_master cap_list
configuration: driver=snd_hda_intel latency=32
resources: irq:129 
memory:f7f20000-f7f23fff memory:f7f00000-f7f0ffff

Kubuntu 19.10
Kernal: 5.3.0-40-generic


I suggest to try the newer guide at It requires the snap package of LXD. For sound, it does not require changes on the host, and passes instead the Unix socket of Pulseaudio to the container.

From the information shown above, I believe that either PA did not start listening to lxdbr0 (require reboot?), or you are using other networking setup than lxdbr0.

1 Like

Thank you, Simos. I am using the newer guide and have run into the following errors:

lxc launch -p default -p x11 ubuntu:18.04 Firefox
Creating Firefox
Starting Firefox
Error: Failed to run: /snap/lxd/current/bin/lxd forkstart Firefox /var/snap/lxd/common/lxd/containers /var/snap/lxd/common/lxd/logs/Firefox/lxc.conf: 
Try `lxc info --show-log local:Firefox` for more info

:~$ lxc info --show-log local:Firefox
Name: Firefox
Location: none
Remote: unix://
Architecture: x86_64
Created: 2020/03/04 10:47 UTC
Status: Stopped
Type: container
Profiles: default, x11


lxc Firefox 20200304104735.703 WARN     cgfsng - cgroups/cgfsng.c:chowmod:1525 - No such file or directory - Failed to chown(/sys/fs/cgroup/unified//lxc.payload/Firefox/, 1000000000, 0)
lxc Firefox 20200304104735.262 ERROR    conf - conf.c:run_buffer:352 - Script exited with status 1
lxc Firefox 20200304104735.262 ERROR    conf - conf.c:lxc_setup:3653 - Failed to run mount hooks
lxc Firefox 20200304104735.262 ERROR    start - start.c:do_start:1321 - Failed to setup container "Firefox"
lxc Firefox 20200304104735.262 ERROR    sync - sync.c:__sync_wait:62 - An error occurred in another process (expected sequence number 5)
lxc Firefox 20200304104735.262 WARN     network - network.c:lxc_delete_network_priv:3377 - Failed to rename interface with index 68 from "eth0" to its initial name "veth33d821bc"
lxc Firefox 20200304104735.262 ERROR    start - start.c:lxc_abort:1122 - Function not implemented - Failed to send SIGKILL to 15026
lxc Firefox 20200304104735.262 ERROR    lxccontainer - lxccontainer.c:wait_on_daemonized_start:873 - Received container state "ABORTING" instead of "RUNNING"
lxc Firefox 20200304104735.262 ERROR    start - start.c:__lxc_start:2039 - Failed to spawn container "Firefox"
lxc 20200304104735.381 WARN     commands - commands.c:lxc_cmd_rsp_recv:135 - Connection reset by peer - Failed to receive response for command "get_state"

Also, interestingly enough, on host $DISPLAY produces:

:0: command not found

Its been that type of day, so far haha.

Thank you for any help you can offer!

These errors do not look like they are related to the x11 profile.
Can you still create containers if you do not specify the x11 profile?
That is, does it work if you run the following:

lxc launch -p default ubuntu:18.04 Firefox

The last command should be echo $DISPLAY and the output will be :0. Without the echo part, the shell tried to execute :0 which does not exist, hence command not found.
Since your $DISPLAY is :0, the x11 profile should mention :0 as well.


Thank you for the “echo” info; that predictably solved my “command not found” “issue”. :flushed:

With respect to creating a container with only the “default” profile, I was able to create the container with no apparent issues. :thinking:

You can take the output of lxc profile show x11 and paste here.
There might be some typo in the profile.

  environment.DISPLAY: :0
  environment.PULSE_SERVER: unix:/home/ubuntu/pulse-native
  nvidia.driver.capabilities: all
  nvidia.runtime: "true"
  user.user-data: |
      - 'sed -i "s/; enable-shm = yes/enable-shm = no/g" /etc/pulse/client.conf'
      - x11-apps
      - mesa-utils
      - pulseaudio
description: GUI LXD profile
    bind: container
    connect: unix:/run/user/1000/pulse/native
    gid: "1000"
    listen: unix:/home/ubuntu/pulse-native
    mode: "0777"
    security.gid: "1000"
    security.uid: "1000"
    type: proxy
    uid: "1000"
    bind: container
    connect: unix:@/tmp/.X11-unix/X0
    listen: unix:@/tmp/.X11-unix/X0
    security.gid: "1000"
    security.uid: "1000"
    type: proxy
    type: gpu
name: x11
- /1.0/instances/Firefox

Looks good.

There is a similar thread at Fail to start container
Can you verify that if you do not set nvidia.runtime in the profile, the container can run?
If that is the case, then the issue that you are facing, is also related to nvidia.runtime.

I’ll check it out later today and report back.

EDIT: Whats the easiest way to edit the x11 profile?

You can edit the profile like this,

EDITOR=nano lxc profile edit x11

That did it! Audio, video, it all works. Thank you!