I'm building a headless softphone application. I know I can build wss or web server with the given tools... but my web app needs to do some pjsip and other codec things with the host's speaker and microphone. Are these devices shared between the mac/windows/linux hosts and the docker container?
To access host machine from the docker container you must attach an IP alias to your network interface. You can bind whichever IP you want, just make sure you're not using it to anything else. Then make sure that you server is listening to the IP mentioned above or 0.0.
You can run both Linux and Windows programs and executables in Docker containers. The Docker platform runs natively on Linux (on x86-64, ARM and many other CPU architectures) and on Windows (x86-64). Docker Inc. builds products that let you build and run containers on Linux, Windows and macOS.
For containers to communicate with other, they need to be part of the same “network”. Docker creates a virtual network called bridge by default, and connects your containers to it. In the network, containers are assigned an IP address, which they can use to address each other.
With Docker for Windows started and Windows containers selected, you can now run either Windows or Linux Containers simultaneously.
I had to use the microphone and speakers of the linux host from a docker container. Since in linux/unix based OSs devices are special files in the file system this solution should apply. In Windows it won't.
I discovered that the ubuntu image I was using in my container didn't have the ALSA drivers needed to use the soundcard. So after installing them in the docker container:
sudo apt-get install -y alsa-base alsa-utils
and running the docker image with the following parameters:
docker run --device /dev/snd:/dev/snd <container_name>
it worked. You can test if it works by invoking aplay
and arecord
inside the container.
Never tried with speakers and microphone, anyway you can access host devices using the option --device
in docker run
.
See Add host device to container (–device) in Docker run reference for more details.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With