Sound devices keep dropping from container

I have a docker container that maps sound devices (speaker and microphone) from the host to the container. Periodically, the container loses these devices and running aplay -l and arecord -l in the container shows the devices are missing, while both devices show up on the host. The host is unfortunately running Ubuntu 16 while the container is running Ubuntu 24. The host environment is pretty tight on memory (2GB), but I am not sure it is a memory issue. Any insight would be appreciated. Below is the docker run command used to start the container:

docker run -it \
  --name laserassistant-latest \
  --privileged \
  --cpuset-cpus="0-3" \
  --memory="8g" \
  --shm-size=4g \
  --ipc=host \
  --device /dev/snd:/dev/snd \
  --device /dev/dri \
  --group-add audio \
  --group-add video \
  -e DISPLAY=:0 \
  -e MESA_GL_VERSION_OVERRIDE=2.1 \
  -e MESA_GLSL_VERSION_OVERRIDE=120 \
  -e GALLIUM_DRIVER=llvmpipe \
  -e LP_NUM_THREADS=4 \
  -e MESA_NO_ERROR=1 \
  -e OMP_NUM_THREADS=4 \
  -e TESSERACT_NUM_THREADS=4 \
  --tmpfs /tmp:rw,noexec,nosuid,size=2g \
  -v /tmp/.X11-unix:/tmp/.X11-unix \
  -v /home/lasersystem/lasersystem/LM_2DVision/recipes:/home/lasersystem/lasersystem/LM_2DVision/recipes:ro \
  --entrypoint /bin/bash \
  laserassistant:latest

Any assistance is greatly appreciated.

Then you must have a pretty old version of Docker or maybe one installed as a Snap package.

Please share the output of the following commands:

docker info
docker version

Review the output before sharing and remove confidential data if any appears (public IP for example)

dpkg -l 'docker*' | grep '^ii'
snap list docker

When you share the outputs, always format your posts according to the following guide: How to format your forum posts


I neved worked with sound devices from Docker containers, but I would start with checking system logs and docker daemon logs. For system logs, I would try journalctl command and/or syslog under /var/log and also the dmesg.command.

but I don’t really know why you would lose a device and even if it happens because of a Docker bug, i you have an old version, that will not be fixed

Docker Version

Docker version 20.10.7, build f0df350

Docker Info

Client:
 Context:    default
 Debug Mode: false
 Plugins:
  app: Docker App (Docker Inc., v0.9.1-beta3)
  buildx: Build with BuildKit (Docker Inc., v0.5.1-docker)
  scan: Docker Scan (Docker Inc., v0.8.0)

Server:
 Containers: 1
  Running: 1
  Paused: 0
  Stopped: 0
 Images: 1
 Server Version: 20.10.7
 Storage Driver: aufs
  Root Dir: /var/lib/docker/aufs
  Backing Filesystem: extfs
  Dirs: 41
  Dirperm1 Supported: true
 Logging Driver: json-file
 Cgroup Driver: cgroupfs
 Cgroup Version: 1
 Plugins:
  Volume: local
  Network: bridge host ipvlan macvlan null overlay
  Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
 Swarm: inactive
 Runtimes: io.containerd.runc.v2 io.containerd.runtime.v1.linux runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: d71fcd7d8303cbf684402823e425e9dd2e99285d
 runc version: b9ee9c6314599f1b4a7f497e1f1f856fe433d3b7
 init version: de40ad0
 Security Options:
  apparmor
  seccomp
   Profile: default
 Kernel Version: 4.13.0-36-generic
 Operating System: Ubuntu 16.04.4 LTS
 OSType: linux
 Architecture: x86_64
 CPUs: 4
 Total Memory: 7.682GiB
 Name: lasersystem-desktop
 ID: KZ27:X2NS:5646:ZFJJ:W5MO:2ZV3:BGHF:P7RC:NZ23:QTV5:BOMA:PC4Y
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 Registry: https://index.docker.io/v1/
 Labels:
 Experimental: false
 Insecure Registries:
  127.0.0.0/8
 Live Restore Enabled: false

WARNING: No swap limit support
WARNING: the aufs storage-driver is deprecated, and will be removed in a future release.

Ubuntu 16.04.4 LTS was released 2018-03-01 and had 5 years of support, it’s end-of-life (unless you pay).

Docker 20.10.7 is from 2021-06-02 and there are probably hundreds of fixes and improvements since then.

So instead of trying to debug outdated software, I recommend to upgrade first.