Hey everyone, I’m running into a roadblock while setting up my Docker container for a NodeJS project. I’m trying to install Puppeteer, but it’s giving me grief on my ARM64 system. Here’s the error I’m getting:
npm ERR! The chromium binary is not available for arm64.
npm ERR! If you are on Ubuntu, you can install with:
npm ERR! sudo apt install chromium
npm ERR! sudo apt install chromium-browser
I’ve tried the usual fixes that work on my local machine, but they’re not cutting it in the Docker environment. Here’s my Dockerfile:
FROM --platform=linux/amd64 node:16-alpine
WORKDIR /app
EXPOSE 8000
ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD true
ENV DOCKER_DEFAULT_PLATFORM "linux/amd64"
COPY . .
RUN apk --no-cache add --virtual builds-deps build-base python3 && \
npm install
CMD ["npm", "start"]
Has anyone else run into this problem? Any tips on getting Puppeteer to play nice with Docker on ARM64? I’m scratching my head here!
I’ve encountered similar issues with Puppeteer on ARM64 systems in Docker. One approach that worked for me was using the ‘browserless/chrome’ image as a separate service in a Docker Compose setup. This way, you can run Puppeteer without needing to install Chromium in your main container.
Your Dockerfile looks good, but you might need to adjust your Node.js code to connect to the browserless service. Here’s a snippet of what your docker-compose.yml might look like:
version: '3'
services:
app:
build: .
depends_on:
- chrome
chrome:
image: browserless/chrome
ports:
- '3000:3000'
Then in your Node.js code, you’d connect to the chrome service like this:
const browser = await puppeteer.connect({ browserWSEndpoint: 'ws://chrome:3000' });
This setup has been reliable for me across different architectures. Hope it helps!
As someone who’s worked extensively with Docker and Puppeteer, I can relate to your frustration. One solution that’s worked wonders for me is using the arm64v8/node
base image instead of the amd64 version. Here’s a tweaked Dockerfile that might do the trick:
FROM arm64v8/node:16-alpine
WORKDIR /app
EXPOSE 8000
RUN apk add --no-cache chromium
ENV PUPPETEER_EXECUTABLE_PATH=/usr/bin/chromium-browser
COPY . .
RUN npm install
CMD ["npm", "start"]
This approach leverages the ARM-compatible Chromium that’s available in Alpine’s package manager. It’s been a game-changer for my ARM64 setups. Just remember to adjust your Puppeteer code to use the PUPPETEER_EXECUTABLE_PATH
environment variable.
If you’re still hitting snags, consider using a multi-stage build to compile any native dependencies. It’s a bit more complex, but it’s saved my bacon more than once when dealing with architecture-specific issues.
yo, i feel ur pain! had same issue last week. try this:
FROM arm64v8/node:16
RUN apt-get update && apt-get install -y chromium
ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true
ENV PUPPETEER_EXECUTABLE_PATH=/usr/bin/chromium
worked like a charm for me. good luck man!