Using sound in a docker environment - githeim/windheim_archive GitHub Wiki
Using sound in a docker environment
Here's how to access sound in a Docker container.
prerequisites for sound
RUN apt install alsa-utils alsa-oss libasound2-dev libasound2-plugins pulseaudio-utils pulseaudio libpulse0
์ปจํ ์ด๋์ host ๋ชจ๋ ์ค์น
docker run command
๋ค์๊ณผ ๊ฐ์ด docker run์ ๋ช ๋ น์ด๋ฅผ ๋ฃ์ด์ค๋ค. pulse audio๋ฅผ ์ฌ์ฉํ๋ ๋ฐฉ๋ฒ
-e PULSE_SERVER=unix:${XDG_RUNTIME_DIR}/pulse/native \
-v ${XDG_RUNTIME_DIR}/pulse/native:${XDG_RUNTIME_DIR}/pulse/native \
-v ~/.config/pulse/cookie:/home/ubuntu/.config/pulse/cookie:ro \
-e PULSE_COOKIE=/home/ubuntu/.config/pulse/cookie \
--device /dev/snd \
--group-add $(getent group audio | cut -d: -f3) \
์
sudo docker run -it --name $CONTAINER_NAME \
--privileged \
--env="DISPLAY=${DISPLAY}" \
--ipc=host \
--net=host \
-e PULSE_SERVER=unix:${XDG_RUNTIME_DIR}/pulse/native \
-v ${XDG_RUNTIME_DIR}/pulse/native:${XDG_RUNTIME_DIR}/pulse/native \
-v ~/.config/pulse/cookie:/home/ubuntu/.config/pulse/cookie:ro \
-e PULSE_COOKIE=/home/ubuntu/.config/pulse/cookie \
--device /dev/snd \
--group-add $(getent group audio | cut -d: -f3) \
-v $DOCKER_SHARED_DIR:/home/ubuntu/share \
$DOCKER_IMG_NAME /bin/bash
ALSA ์ง์ ์ ๊ทผ ์
sudo docker run -it --name $CONTAINER_NAME \
--privileged \
--env="DISPLAY=${DISPLAY}" \
--ipc=host \
--net=host \
--device /dev/snd \
--group-add $(getent group audio | cut -d: -f3) \
-v /etc/asound.conf:/etc/asound.conf:ro \
-v $DOCKER_SHARED_DIR:/home/ubuntu/share \
$DOCKER_IMG_NAME /bin/bash