puppeteer: [Bug]: Docker image not running on Macos m1

Bug expectation

Dockerfile not running on Macos m1

Here’s the output image

Minimal, reproducible example

#Base dockerfile 

FROM node:18

RUN apt-get update \
 && apt-get install -y chromium \
    fonts-ipafont-gothic fonts-wqy-zenhei fonts-thai-tlwg fonts-kacst fonts-freefont-ttf libxss1 \
    --no-install-recommends
    
ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true
ENV PUPPETEER_EXECUTABLE_PATH=/usr/bin/chromium

# /...Copy project and install dependencies

Error string

Error: Failed to launch the browser process! Error: Can’t open display:

Puppeteer configuration

const browser = await puppeteer.launch({
    timeout: 0,
    headless: true,
    executablePath: "/usr/bin/chromium",
    args: ['--no-sandbox']
  });

Puppeteer version

19.7.2

Node version

18.0.0

Package manager

yarn

Package manager version

1.22.19

Operating system

macOS

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Reactions: 4
  • Comments: 22 (1 by maintainers)

Most upvoted comments

@OrKoN @DenisRukavitsa Yes even with Rosetta for x86/amd64 turned on and puppeteer with headless mode. it doesn’t work.

Have you enabled the beta feature ‘Use Rosetta for x86/amd64 emulation on Apple Silicon’ via the docker settings? I think it is very likely the cpu architecture mismatch.

Hello! I have enabled Rosetta in the Docker Desktop settings. But another error appears when starting the container.

ilya@MacBook-Pro puppeteer % docker-compose up
[+] Running 2/1
 ⠿ Network puppeteer_default        Created                                                                                             0.0s
 ⠿ Container puppeteer-puppeteer-1  Created                                                                                             0.0s
Attaching to puppeteer-puppeteer-1
puppeteer-puppeteer-1  | [1:35:0511/090406.019187:ERROR:bus.cc(399)] Failed to connect to the bus: Failed to connect to socket /run/dbus/system_bus_socket: No such file or directory
puppeteer-puppeteer-1  | [1:1:0511/090406.100099:ERROR:ozone_platform_x11.cc(239)] Missing X server or $DISPLAY
puppeteer-puppeteer-1  | [1:1:0511/090406.100142:ERROR:env.cc(255)] The platform failed to initialize.  Exiting.
puppeteer-puppeteer-1 exited with code 1
version: '3'
services:
    puppeteer:
        image: ghcr.io/puppeteer/puppeteer:latest
        platform: linux/amd64
        cap_add:
            - SYS_ADMIN

Have you enabled the beta feature ‘Use Rosetta for x86/amd64 emulation on Apple Silicon’ via the docker settings? I think it is very likely the cpu architecture mismatch.

@eryk-vieira , did you manage to solve the issue? I’m having the same error - Can't open display: . I tried several Dockerfile configurations, using node / alpine images, with / without executablePath and playing around with args but no luck.

@Lightning00Blade Already tried that. Unfortunately, it doesn’t work as well I get the same error:

Error: Failed to launch the browser process! spawn /usr/bin/chromium ENOENT

And I’m making sure to remove the executablePath param.

image

I don’t have a Mac ARM on hand to test. I will ask one of the other maintainers to check it out. I would suggest you try the official image without specifying the executablePath, that way Puppeteer will use the one it installs.