0

I have a small dotnet client that runs videos using mplayer on Raspbian.

When logged in via SSH, I can run mplayer manually providing i set the DISPLAY variable to :0 and run mplayer as follows:

mplayer -vo gl video.mp4

This will display the video on the Raspberry Pi's screen when logged in remotely.

I am trying to create a docker image and deployment where I can do the same thing from a docker container.

The Dockerfile looks like this:

FROM mcr.microsoft.com/dotnet/sdk:6.0.202-bullseye-slim-arm64v8 AS build

WORKDIR /src

COPY ["presentationtv-client/PresentationTV.Client.csproj", "presentationtv-client/"]

RUN dotnet restore "presentationtv-client/PresentationTV.Client.csproj"

COPY . .

WORKDIR /src/presentationtv-client
RUN dotnet build "PresentationTV.Client.csproj" -c Release --no-restore

FROM build AS publish
WORKDIR /src/presentationtv-client
RUN dotnet publish "PresentationTV.Client.csproj" -c Release -o /app/publish --no-build

FROM mcr.microsoft.com/dotnet/aspnet:6.0.4-bullseye-slim-arm64v8 AS final
WORKDIR /

RUN \
    apt-get -y update && \
    apt-get -y upgrade && \
    apt-get -y install curl mplayer bash-completion

RUN mkdir -p /tvclient/runtime
RUN mkdir -p /tvclient/logs
RUN mkdir -p /tvclient/storage

ADD presentationtv-client/appsettings.json.linux /tvclient/appsettings.json
ADD presentationtv-client/appsettings.json.linux /tvclient/runtime/appsettings.json
ENV DISPLAY=:0

COPY --from=publish /app/publish/ /tvclient/runtime

#ENTRYPOINT ["dotnet", "/tvclient/runtime/PresentationTVClient.dll"]
ENTRYPOINT ["tail", "-f", "/dev/null"]

And my docker-compose :

version: "3.0"
services:
  tvclient:
    image: tvclient
    container_name: tvclient
    network_mode: "host"
    environment:
      - DISPLAY=:0
      - UID=0
      - GID=0
    volumes:
      - /etc/localtime:/etc/localtime:ro
      - ./storage:/tvclient/storage
      - ./logs:/tvclient/logs
    devices:
      - /dev/vchiq:/dev/vchiq # MMAL/OMX on Raspberry Pi
    deploy:
      resources:
        limits:
          cpus: '1.0'
    restart: unless-stopped

When I exec into the container and run mplayer manually to test if it works I get the following error:

No protocol specified
vo: couldn't open the X11 display (:0)!
No protocol specified
No protocol specified
No protocol specified

My guess is I cannot interface with the X11 driver or there is no driver supported.

I am not really sure what I need to do to get it working. It needs to be with some form of acceleration else the full screen video is too slow (from my tests just running locally on the Pi).

Nicol Bolas
  • 449,505
  • 63
  • 781
  • 982
Reptile
  • 353
  • 1
  • 2
  • 12
  • The wiring to get X working in a Docker container is somewhat complex, and if you're trying to read from a host device and display to the local display then it might be much easier to run the program outside a container. Does [Can you run GUI applications in a Linux Docker container?](https://stackoverflow.com/questions/16296753/can-you-run-gui-applications-in-a-linux-docker-container) have enough information for your needs? – David Maze Apr 28 '22 at 13:58
  • Using the hosts mplayer is absolutely a fine solution for me. I am still unsure how to achieve this. I already tested /tmp/.X11-unix in the docker-compose volume section but couldn't get it to work. I will have a thorough read through tomorrow if no one can point me in the right direction here. Thanks! – Reptile Apr 28 '22 at 19:37

0 Answers0