whatsapp-web.js: Can't run Whatsapp-web.js on Docker Container
Is there an existing issue for this?
- I have searched the existing issues
Describe the bug
I am trying to put my app inside a Docker Container. I am able to build it correctly after a lot of looking around but i am facing this issue.
Dockerfile
FROM node:18
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 \
--no-install-recommends \
&& rm -rf /var/lib/apt/lists/*
# Set the working directory
WORKDIR /app
# Copy your application files into the container
COPY . .
# Install your Node.js application dependencies
RUN npm install
# Build your application
RUN npm run build
# Expose the port your application runs on
EXPOSE 3000
# Start your Node.js application
CMD ["node", "dist/server/server.js"]
Expected behavior
Normal initialization of the Whatsapp-web.js Client code.
Steps to Reproduce the Bug or Issue
Run the normal example on Docker.
This is my build command:
docker build --platform linux/amd64 --no-cache -t whatsappclient:development .
Run command:
docker run --platform linux/amd64 -p 3000:3000 whatsappclient:development
Error Code:
/app/node_modules/whatsapp-web.js/node_modules/puppeteer/lib/cjs/puppeteer/node/BrowserRunner.js:241
reject(new Error([
^
Error: Failed to launch the browser process!
qemu: uncaught target signal 5 (Trace/breakpoint trap) - core dumped
qemu: uncaught target signal 5 (Trace/breakpoint trap) - core dumped
[0928/234157.110661:ERROR:bus.cc(406)] Failed to connect to the bus: Failed to connect to socket /run/dbus/system_bus_socket: No such file or directory
[0928/234157.303689:ERROR:scoped_ptrace_attach.cc(27)] ptrace: Function not implemented (38)
Assertion failed: p_rcu_reader->depth != 0 (/qemu/include/qemu/rcu.h: rcu_read_unlock: 101)
TROUBLESHOOTING: https://github.com/puppeteer/puppeteer/blob/main/docs/troubleshooting.md
at onClose (/app/node_modules/whatsapp-web.js/node_modules/puppeteer/lib/cjs/puppeteer/node/BrowserRunner.js:241:20)
at ChildProcess.<anonymous> (/app/node_modules/whatsapp-web.js/node_modules/puppeteer/lib/cjs/puppeteer/node/BrowserRunner.js:232:79)
at ChildProcess.emit (node:events:529:35)
at ChildProcess._handle.onexit (node:internal/child_process:292:12)
Node.js v18.18.0
Browser Type
Google Chrome
WhatsApp Account Type
Standard
Does your WhatsApp account have multidevice enabled?
Yes, I am using Multi Device
Environment
“whatsapp-web.js”: “1.22.2-alpha.0” Node.js: 18
Additional context
No response
About this issue
- Original URL
- State: closed
- Created 9 months ago
- Reactions: 1
- Comments: 28 (1 by maintainers)
Using Zenika Docker Image
Dockerfile with comments
Dockerfile without comments
server.js
It’s not the whole file but the important bits.
Build image and run
Project Structure
Other comments
authandcachedir so that when you deploy new code you don’t have to login again.Try this using the default browser
It worked for me.
This worked perfectly, thank you!
I’ll post my configs that’s working:
Dockerfile:
Client instance:
Hope it helps