Running in Docker
See original GitHub issueHi @lucacasonato !
I am trying to create a docker image where I use Deno with Oak and Puppeteer, but I am having some issues with Puppeteer. So far, this is my docker image, but I cannot seem to make it work. I have two main issues at the moment:
1: The install script does not seem to recognize that an existing installation exists 2: Puppeteer is not able to run the downloaded chromium
Here is my Dockerfile (assume that all the variables are set). Let me know if I can provide you with any other information!
FROM hayd/alpine-deno:1.7.2
EXPOSE ${MICROSERVICE_PORT}
WORKDIR /app
# As provided by https://github.com/puppeteer/puppeteer/blob/main/docs/troubleshooting.md#running-on-alpine
RUN apk add --no-cache \
nss \
freetype \
freetype-dev \
harfbuzz \
ca-certificates \
ttf-freefont
ENV PUPPETEER_EXECUTABLE_PATH=/deno-dir/deno_puppeteer/chromium/linux-818858/chrome-linux/chrome
ADD . .
RUN PUPPETEER_PRODUCT=chrome deno run -A --unstable https://deno.land/x/puppeteer@${PUPPETEER_VERSION}/install.ts
RUN deno install -qAf --unstable https://deno.land/x/denon/denon.ts
RUN deno cache --unstable src/deps.ts
RUN deno cache --unstable src/mod.ts
USER deno
ENTRYPOINT [ "denon"]
CMD ["run","--unstable","-A","src/mod.ts" ]
This is the error that I am receiving when I try to use Puppeteer:
Error: Failed to launch the browser process!
TROUBLESHOOTING: https://github.com/puppeteer/puppeteer/blob/main/docs/troubleshooting.md
at waitForWSEndpoint (BrowserRunner.ts:174:9)
at async BrowserRunner.setupConnection (BrowserRunner.ts:143:31)
at async ChromeLauncher.launch (Launcher.ts:108:26)
at async createPDF (pdf-handler.ts:4:19)
at async routes.ts:14:19
at async dispatch (middleware.ts:41:7)
at async dispatch (middleware.ts:41:7)
at async dispatch (middleware.ts:41:7)
at async Application.#handleRequest (application.ts:252:9)
Issue Analytics
- State:
- Created 3 years ago
- Reactions:2
- Comments:6 (1 by maintainers)
Top Results From Across the Web
docker run - Docker Documentation
The docker run command first creates a writeable container layer over the specified image, and then starts it using the specified command.
Read more >How To Use docker exec to Run Commands in ... - DigitalOcean
Running Commands in an Alternate Directory in a Docker Container. To run a command in a certain directory of your container, use the...
Read more >A Docker Tutorial for Beginners
We can download and run the image directly in one go using docker run . As noted above, the --rm flag automatically removes...
Read more >Running Containers – Introduction to Docker - GitHub Pages
To use a Docker image as a particular instance on a host machine you run it as a container. You can run in...
Read more >Docker basics: how to start and stop containers - Elder Moraes
If you skip the TAG and DIGEST command parameters, Docker will run the container based on the image tagged latest. The docker run...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi @lucacasonato, @halvardssm.
I solved this. I checked the error message by adding
console.log (line);
between lines 167 and 168 ofBrowserRunner.ts
indeno-puppeteer
. I found that the cause of the error was that some required packages were not installed. The packages listed in troubleshooting ofpuppeteer
are not enough for Docker containers, need the following:And one more important thing is written here. If we run as root user inside a Docker container, we need to use
--no-sandbox
mode when launching Puppeteer. Otherwise error will occur. Yet one more thing, Troubleshooting has tips on shared memory issues in Docker containers. Based on these, the parameters of thelaunch
method should be as follows:This is my Dockerfile:
Thank you.
Added an example Dockerfile and info to the README. Thanks everyone for figuring this out. Especially @mt-u who got it working in the end 😃