I have a docker container running on a raspberry pi 5 and my goal is to access the alsa audio devices of the raspy inside of the container.
Currently I get the following error when executing
aplay someaudio.wav
aplay: main:831: audio open error: Unknown error 524
Outside of the container audio is working
My dockerfile looks like this:
FROM python:3.12.4-slim-bookworm
ARG TARGETARCH
RUN apt update && apt upgrade -y && \
apt install -y wget gcc swig libmariadb-dev libasound2-dev alsa-utils
RUN if [ "$TARGETARCH" == "armhf" ]; then\
apt install build-essentials cmake -y ; \
else \
apt install build-essential -y ; \
fi
COPY src/app /app
RUN pip install -r /app/requirements.txt
WORKDIR /app
ENTRYPOINT [ "uvicorn", "app:app", "--port", "8000", "--host", "0.0.0.0" ]
and this is the docker-compose
backend:
image: pythonbasedimage
volumes:
- ${PWD}/.env:/app/.env
devices:
- "/dev/snd:/dev/snd"
privileged: true
ports:
- "8000:8000"
deploy:
resources:
limits:
cpus: "0.5"
alsactl info
shows the following:
#
# Sound card
#
- card: 0
id: vc4hdmi0
name: vc4-hdmi-0
longname: vc4-hdmi-0
driver_name: vc4-hdmi
mixer_name:
components:
controls_count: 5
pcm:
- stream: PLAYBACK
devices:
- device: 0
id: MAI PCM i2s-hifi-0
name: MAI PCM i2s-hifi-0
subdevices:
- subdevice: 0
name: subdevice #0
alsactl: rawmidi_device_list:105: snd_ctl_rawmidi_next_device
someaudio.wav
file accessible from within the container via some volume mapping? Have you tried to search for the error codeUnknown error 524
?.wav
file into the container and directly executeaplay someaudio.wav
as theENTRYPOINT
to see if that works with the current dependencies and maybe add more (or change base image) to see if that solves the issue.