Hi,
I’m trying to play mp3 files in docker container on RPI4 board. In the container I use nodejs and MPV to play mp3 files.
Actually I have succeeded it on Raspbian and now it’s time to give it a try on BalenaOS. I use node:14-bullseye as a base image on Rasbian.
Here is my docker-compose file. I mounted the sound device /dev/snd
also.
docker-compose.yaml
version: '2.4'
services:
component:
build:
context: .
dockerfile: Dockerfile_balena
image: musicplayer
network_mode: 'host'
restart: unless-stopped
devices:
- "/dev/snd"
privileged: true
environment:
- ENDPT_ADDR=${ENDPT_ADDR}
Dockerfile_balena
FROM balenalib/raspberrypi4-64-debian-node:14-sid
RUN apt update
RUN apt -y install nmap
RUN apt -y install cmake build-essential libssl-dev python3 ssh sshpass
RUN npm install -g --unsafe-perm pm2
RUN pm2 install pm2-logrotate
RUN pm2 set pm2-logrotate:retain 7
RUN mkdir -p /work/dist
WORKDIR /work
RUN mkdir -p /greengrass/v2/
COPY crt/* /greengrass/v2/
COPY lounge-info.json /greengrass/v2/
RUN apt install -y mpv
COPY package.json /work/
COPY .npmrc /work/
RUN yarn install
COPY component.json /work/
COPY ecosystem.config.js /work/
COPY tsconfig.json /work/
COPY dist /work/dist
CMD pm2-runtime start ecosystem.config.js
When I run this service, I noticed that errors occurred without detailed message.
So I run the mpv in the container with this command mpv --no-video /music/piano1.mp3
. Please refer to the logs
root@c2e8aeb:/var/log# mpv --no-video /music/piano1.mp3
[W][02258.304617] pw.conf | [ conf.c: 939 try_load_conf()] can't load config client.conf: No such file or directory
[E][02258.304684] pw.conf | [ conf.c: 963 pw_conf_load_conf_for_context()] can't load default config client.conf: No such file or directory
[ao/alsa] Playback open error: No such device
Cannot connect to server socket err = No such file or directory
Cannot connect to server request channel
jack server is not running or cannot be started
JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for -1, skipping unlock
JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for -1, skipping unlock
[ao/jack] cannot open server
[ao/sdl] could not open audio: ALSA: Couldn't open audio device: No such device
[ao] Failed to initialize audio driver 'sdl'
Could not open/initialize audio device -> no sound.
Audio: no audio
Exiting... (Errors when loading file)
In the /dev/
directory in the container, there are devices like below
root@c2e8aeb:/dev# ls
ashmem cpu_dma_latency gpiochip1 kvm loop6 mmcblk0p4 ptmx ram14 ram8 rpivid-vp9mem stdout tty14 tty21 tty29 tty36 tty43 tty50 tty58 tty8 vc-mem vcs5 vcsa6 vga_arbiter
autofs cuse gpiomem loop-control loop7 mmcblk0p5 pts ram15 ram9 shm tty tty15 tty22 tty3 tty37 tty44 tty51 tty59 tty9 vchiq vcs6 vcsu vhci
btrfs-control dma_heap hwrng loop0 mapper mmcblk0p6 ram0 ram2 random snapshot tty0 tty16 tty23 tty30 tty38 tty45 tty52 tty6 ttyAMA0 vcio vcsa vcsu1 vhost-net
bus dri i2c-1 loop1 mem mqueue ram1 ram3 raw snd tty1 tty17 tty24 tty31 tty39 tty46 tty53 tty60 ttyprintk vcs vcsa1 vcsu2 vhost-vsock
cachefiles fd i2c-20 loop2 mmcblk0 net ram10 ram4 rfkill spidev0.0 tty10 tty18 tty25 tty32 tty4 tty47 tty54 tty61 ubi_ctrl vcs1 vcsa2 vcsu3 watchdog
cec0 full i2c-21 loop3 mmcblk0p1 null ram11 ram5 rpivid-h264mem spidev0.1 tty11 tty19 tty26 tty33 tty40 tty48 tty55 tty62 uhid vcs2 vcsa3 vcsu4 watchdog0
cec1 fuse input loop4 mmcblk0p2 port ram12 ram6 rpivid-hevcmem stderr tty12 tty2 tty27 tty34 tty41 tty49 tty56 tty63 uinput vcs3 vcsa4 vcsu5 zero
console gpiochip0 kmsg loop5 mmcblk0p3 ppp ram13 ram7 rpivid-intcmem stdin tty13 tty20 tty28 tty35 tty42 tty5 tty57 tty7 urandom vcs4 vcsa5 vcsu6 zram0
I’m wondering what I am supposed to do.
Please help.
Thank you