Cant launch chrome in docker linux container
-
I have an asp.net core application that I am deploying in a linux docker container. I seem to be having trouble getting chrome to launch when I run a report. I am getting the error:
Failed to launch chrome! Running as root without --no-sandbox is not supported.
I have followed the directions on the .net local reporting page here (https://jsreport.net/learn/dotnet-local) and made the neccesarry modifications for running chrome in linux, but I am still getting the error.
Here is my full docker file:
#use the .net core 2.1 runtime default image FROM microsoft/dotnet:2.1-aspnetcore-runtime #set the working directory to the server WORKDIR /server #copy all contents in the current directory to the container server directory COPY . /server #install node RUN apt-get update -yq \ && apt-get install curl gnupg -yq \ && curl -sL https://deb.nodesource.com/setup_8.x | bash \ && apt-get install nodejs -yq #install jsreport-cli RUN npm install jsreport-cli -g #install chrome for jsreport linux RUN apt-get update && \ apt-get install -y gnupg libgconf-2-4 wget && \ wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - && \ sh -c 'echo "deb [arch=amd64] 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-unstable --no-install-recommends ENV chrome:launchOptions:args --no-sandbox #expose port 80 EXPOSE 80 CMD dotnet Server.dll
Is there another step that I am missing somewhere? Thanks in advance for any help!
-
The same dockerfile works for me.
Is this your whole dockerfile? Don't you have there another building section?
-
This is the entire docker file. I did find out that for some reason using
CMD dotnet Server.dll
made it so my program did not have access to the environment variables set in the docker file. If I set the environment variables in C#, just before running a report, everything worked fine. However, when I changdedCMD dotnet Server.dll
toENTRYPOINT ["dotnet", "Server.dll"]
I was able to run reports as expected.
-
Thank you for sharing.
Now I see it also in the docs
https://docs.docker.com/engine/reference/builder/#cmd
CMD
doesn't propagate variables.