0

I have implemented a tutorial application.

This application is docker-pushed on dockerhub.com. So you can simply test it on Ubuntu/Linux under conditions of disclaimer:

# xhost +local:
# XSOCK=/tmp/.X11-unix
# docker run -v $XSOCK:$XSOCK jumogehn/tutorial:0.1

This application is a simple gtk3 app built against wxwidgets library. It runs well in and out of the docker. So far so good except one thing - it doesn't play a button click sound ONLY when it's in the docker container.

I have searched for this problem in this stackoverflow. There were some QnAs about some sound play issue regarding docker container. But they didn't talk about gtk3. I saw something about pulseaudio related talks... But those are not easy for me... I'd like to find some advice for my case - button click sound of gtk3 application.

The Dockerfile is as shown below:

FROM ubuntu:20.04

LABEL email="jumogehn@gmail.com"
LABEL version="0.1"
LABEL description="Contains basic WxWidgets Application - tutorial. You can use this image as a base image for your WxWidgets application."

ENV DEBIAN_FRONTEND=noninteractive
ENV DISPLAY :0

# Make sure you can build docker image after you finished building debian intalling package
RUN if ! [ -f "tutorialpkg-0.1.1-Linux.deb" ]; then \
  echo "There is no installer package file. Do the following:\n" \
  echo "  cp ../build/tutorialpkg-0.1.1-Linux.deb ." \
  exit 1; \
fi

RUN apt update
RUN apt install -y gnupg gnupg2 gnupg1
RUN apt-key adv --fetch-keys https://repos.codelite.org/CodeLite.asc
RUN apt install -y software-properties-common

RUN export ARCH=$(dpkg --print-architecture); \
    if [ "$ARCH" = "amd64" ]; then apt-add-repository 'deb [arch=amd64] https://repos.codelite.org/wx3.1.5/ubuntu/ focal universe'; \
                              else apt-add-repository 'deb https://repos.codelite.org/wx3.1.5/ubuntu/ focal universe'; \
    fi

RUN apt update
RUN apt install -y libwxbase3.1-0-unofficial libwxbase3.1unofficial-dev libwxgtk3.1-0-unofficial libwxgtk3.1unofficial-dev wx3.1-headers wx-common libwxgtk-media3.1-0-unofficial
RUN apt install -y libwxgtk-media3.1unofficial-dev libwxgtk-webview3.1-0-unofficial libwxgtk-webview3.1unofficial-dev libwxgtk-webview3.1-0-unofficial-dbg libwxbase3.1-0-unofficial-dbg
RUN apt install -y libwxgtk3.1-0-unofficial-dbg libwxgtk-media3.1-0-unofficial-dbg wx3.1-i18n wx3.1-examples
RUN apt install -y libgtk-3-0 libsm6 libxext6 libxrender-dev libnotify-dev
RUN apt install -qqy x11-apps
RUN apt update
RUN mkdir -p /opt
COPY tutorialpkg-0.1.1-Linux.deb /opt
RUN dpkg -i /opt/tutorialpkg-0.1.1-Linux.deb

CMD [ "tutorial", "", "" ]
Jumogehn
  • 1,102
  • 3
  • 11
  • 29
  • I'd recommend running it outside a container directly on the host. That way it can access the display, user preferences, sound, _etc._ without having to do any complex or unusual setup to avoid Docker's standard isolation features. – David Maze Feb 05 '22 at 15:50
  • @DavidMaze Thank you for the advice. If my intent was implementing a practical application, I would agree with your suggestion. But my intent is not. I want to learn about docker and other useful knowledge - cmake, cpack, wxwidgets,... So this is a question for knowledge. It's not for making better practical application. I guess you could understand now. – Jumogehn Feb 06 '22 at 00:46
  • when you execute your docker container what OS are you on ? you may need to connect the dots between parent host OS and child inside the container which is ubuntu ... I suggest you get ahold of a junker laptop and wipe its drive to erase windows and install Ubuntu 20.04 onto the laptop and start from here ... YMMV the tutorial you mention in your doc is https://www.informit.com/articles/article.aspx?p=606222 for others benefit ... have fun – Scott Stensland Feb 06 '22 at 13:16
  • 1
    @ScottStensland Thank you for the comment. I am now using a laptop equipped by Ubuntu 20.04... – Jumogehn Feb 06 '22 at 13:27
  • I will look into https://forums.docker.com/t/how-to-get-sound/36527 and https://github.com/TheBiggerGuy/docker-pulseaudio-example – Jumogehn Feb 06 '22 at 14:06
  • https://discuss.linuxcontainers.org/t/audio-via-pulseaudio-inside-container/8768 and https://blog.simos.info/running-x11-software-in-lxd-containers/ added to my investigation list – Jumogehn Feb 12 '22 at 10:59
  • https://stackoverflow.com/questions/28985714/run-apps-using-audio-in-a-docker-container another example – Jumogehn Feb 19 '22 at 00:41

0 Answers0