'Node.js + puppeteer failing in docker: error while loading shared libraries: libX11-xcb
i am having a node.js application which i want to run in docker-compose
here is my dockerfile:
FROM node:latest
WORKDIR /app
COPY package.json /app
RUN npm install --save app
COPY . /app
CMD ["yarn", "add", "puppeteer"]
and here is my compose:
version: "3.9"
services:
insta-bot:
build:
context: ./
dockerfile: ./Dockerfile
entrypoint: ["node", "/app/example.js"]
when i do docker-compose up it container fails with this error:
Error: Failed to launch chrome!
my-service | /app/node_modules/puppeteer/.local-chromium/linux-686378/chrome-linux/chrome: error while loading shared libraries: libX11-xcb.so.1: cannot open shared object file: No such file or directory
Solution 1:[1]
Resolved my issue with adding to dockerfile this:
RUN apt-get update
RUN apt-get install -y 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 libnss3 lsb-release xdg-utils wget
and for puppeteer launch in script this:
browser = await puppeteer.launch({ headless: true,args: ['--no-sandbox','--disable-setuid-sandbox'] });
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | user18336439 |
