我需要使用Chrome在docker内部启动Puppeteer headfull(无头假),并且出现相同的错误:“无法启动chrome”。
我安装了所有依赖项,但是随时都会掉下来
Error: Failed to launch chrome!
TROUBLESHOOTING: https://github.com/GoogleChrome/puppeteer/blob/master/docs/troubleshooting.md
at onClose (/app/node_modules/puppeteer/lib/Launcher.js:339:14)
at ChildProcess.helper.addEventListener (/app/node_modules/puppeteer/lib/Launcher.js:329:60)
at emitTwo (events.js:131:20)
at ChildProcess.emit (events.js:214:7)
at Process.ChildProcess._handle.onexit (internal/child_process.js:198:12)
Dockerfile
FROM node:8
RUN apt-get update && apt-get install -yq --no-install-recommends tightvncserver xfce4 xfce4-goodies apt-utils gconf-service libasound2 libatk1.0-0 libc6 libcairo2 libcups2 libdbus-1-3 libexpat1 libfontconfig1 libgcc1 libgconf-2-4 libgdk-pixbuf2.0-0 libglib2.0-0 libgtk-3-0 libnspr4 libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcomposite1 libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 libxtst6 ca-certificates fonts-liberation libappindicator1 libnss3 lsb-release xdg-utils wget x11vnc x11-xkb-utils xfonts-100dpi xfonts-75dpi xfonts-scalable xfonts-cyrillic x11-apps xvfb apt-utils openvpn fping nano
RUN mkdir -p /app
WORKDIR /app
COPY . /app
# Install Chrome
#RUN wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
#RUN dpkg -i google-chrome-stable_current_amd64.deb; apt-get -fy install
# Disable puppeteer chromium installation
#ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD true
# Install Puppeteer under /node_modules so it's available system-wide
ADD package.json package-lock.json /
RUN npm install
# Start server on port 3000
EXPOSE 3000
# Start script on Xvfb
CMD xvfb-run --server-args="-screen 0 1024x768x24" npm start
# VNC Server
CMD vncserver
CMD nc localhost 5901
CMD export DISPLAY=:1
CMD xhost +
# Running app
CMD node app.js