How to play sound in a docker container

后端 未结 1 2101
眼角桃花
眼角桃花 2020-12-08 21:15

I\'m trying to dockerize a text to speech application for sharing the code with other developers, however the issue I am having right now is the docker container cannot find

相关标签:
1条回答
  • 2020-12-08 21:32

    It is definitely possible, you need to mount /dev/snd, see how Jess Frazelle launches a Spotify container, from

    https://blog.jessfraz.com/post/docker-containers-on-the-desktop/

    you will notice

    docker run -it \
        -v /tmp/.X11-unix:/tmp/.X11-unix \ # mount the X11 socket
        -e DISPLAY=unix$DISPLAY \ # pass the display
        --device /dev/snd \ # sound
        --name spotify \
        jess/spotify
    

    or for Chrome, at the end

    docker run -it \
        --net host \ # may as well YOLO
        --cpuset-cpus 0 \ # control the cpu
        --memory 512mb \ # max memory it can use
        -v /tmp/.X11-unix:/tmp/.X11-unix \ # mount the X11 socket
        -e DISPLAY=unix$DISPLAY \ # pass the display
        -v $HOME/Downloads:/root/Downloads \ # optional, but nice
        -v $HOME/.config/google-chrome/:/data \ # if you want to save state
        --device /dev/snd \ # so we have sound
        --name chrome \
        jess/chrome
    
    0 讨论(0)
提交回复
热议问题