I have a use-case where i have to run chrome headful (headless false) in a docker container.
The error i get is Missing X server or $DISPLAY
.
Here’s the example code i’m using:
#See https://aka.ms/customizecontainer to learn how to customize your debug container and how Visual Studio uses this Dockerfile to build your images for faster debugging.
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base
USER app
WORKDIR /app
EXPOSE 8080
EXPOSE 8081
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
ARG BUILD_CONFIGURATION=Release
WORKDIR /src
COPY ["blazor-in-container.csproj", "."]
RUN dotnet restore "./././blazor-in-container.csproj"
COPY . .
WORKDIR "/src/."
RUN dotnet build "./blazor-in-container.csproj" -c $BUILD_CONFIGURATION -o /app/build
FROM build AS publish
ARG BUILD_CONFIGURATION=Release
RUN dotnet publish "./blazor-in-container.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
USER root
#####################
#PUPPETEER RECIPE
#####################
RUN apt-get update
&& apt-get install -y wget gnupg
&& wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | gpg --dearmor -o /usr/share/keyrings/googlechrome-linux-keyring.gpg
&& sh -c 'echo "deb [arch=amd64 signed-by=/usr/share/keyrings/googlechrome-linux-keyring.gpg] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list'
&& apt-get update
&& apt-get install -y google-chrome-stable fonts-ipafont-gothic fonts-wqy-zenhei fonts-thai-tlwg fonts-khmeros fonts-kacst fonts-freefont-ttf libxss1 dbus dbus-x11
--no-install-recommends
&& service dbus start
&& rm -rf /var/lib/apt/lists/*
ENV PUPPETEER_EXECUTABLE_PATH "/usr/bin/google-chrome-stable"
USER app
ENTRYPOINT ["dotnet", "blazor-in-container.dll"]
here’s the example code: https://github.com/Marcel0024/puppeteer-sharp-on-blazor-docker-demo/tree/main
i’ve tried to use xvfb
but coudn’t hook it up with puppeteer sharp. Any ideas?