How to create sound devices for debian in docker?
Asked Answered
S

1

13

I'm using various docker containers which, under the covers are built on Debian sid. These images lack /dev/snd and /dev/snd/seq, which pretty much makes sense since they have no hardware audio card.

Several pieces of software I'm using to generate MIDI files require these sequencer devices to be present. They're not necessarily used to send out audio, but the code itself dies in init if the sound devices do not exist. To be clear, I don't need to generate an audio signal within docker, rather I just need these to exist to make other software happy.

So far, what I've tried is endlessly installing various alsa packages (alsa-utils, alsa-oss, and others) and trying to modprobe my way out of this, all with no luck.

Within a docker container, what needs to happen to have valid audio devices even if dummy?

Sidwell answered 13/9, 2017 at 23:30 Comment(14)
I was setting up google home in a docker container on a rasberrypi running raspbian couple weeks back. Even after installing the sound drivers (alsa-utils) google home just would not start if I dont plugin a sound device. You already understand this going by your question. All I can say is may be there is no other way :(Haustellum
See if this helps. You need to mount the /dev/snd from host blog.jessfraz.com/post/docker-containers-on-the-desktopSophisticated
@TarunLalwani I've seen references to --device /dev/snd elsewhere, but this guidance is from 2015, and the official docker docs don't mention that --device is a valid option, I think this was deprecated/removed.Sidwell
Doesn't --device /dev/snd/seq:/dev/snd/seq work?Joule
@FrobberOfBits, who says its not there in documentation? Please check docs.docker.com/engine/reference/run/…Sophisticated
Sorry -- my mistake; --device is documented, but still isn't helpful when bridging with Mac OS X, because it uses CoreAudio. Need to dig further on that #14867533Sidwell
Note that bridging to my host OS's sound hardware isn't strictly necessary. I don't need sound output, I only need to make software happy which expects that capabilitySidwell
this certainly is solvable since I have installed ubuntu on my mac as a dual boot and sound ran fineWilcher
Have you tried this? #40137106Kentigera
Also, and this might be the last option, you can install Ubuntu (or any other linux distro) in VirtualBox and then work on your Docker shenanigans inside that VM? Since, Ubuntu will have access to your Mac's Audio, and since it is Ubuntu so it can bridge its audio(which is technically, your Mac's) to the docker container, I believe it might solve your problem.Kentigera
@AbhishekSoni I appreciate the suggestion; I can manage to get audio bridged to a mac, but this isn't really a workable solution, because it requires modifying the host OS. The objective isn't to bridge audio, it's to make the software that requires the device happy. This may work for a mac host, but the point of doing this in docker is so that it can be deployed elsewhere, and I can't modify the host OS everywhere I go, nor will the host OS always be running Mac OS X.Sidwell
How are you connecting the sequencer devices to your mac? Perhaps if they're connected via usb you could share the /dev/bus/usb to the docker container and it could have its own software to interpret the usb device as the audio device it needs.Vassily
I think this has been solved. If all you need is the directories, just mount them as volumes to some other directory that exists on the host. #28986214Trellas
Inside of your Dockerfile, what happens when you call touch /dev/snd? How about if you instead make a dummy character device, for example by using mknod /dev/snd c 89 1? If these commands do no work, then what errors do they raise?Kt
F
1

I've had success getting sound through Docker (not the same problem, I know) by adding the devices whe running the container.

docker run -it --device /dev/snd myimage

The permissions can get challenging very quickly, you might want to try initially using --device /dev/snd along with --privileged and then dial back privileges little by little once it works.

Floatfeed answered 3/2, 2020 at 5:45 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.