linuxdockerpuppeteerchromiumapple-m1

Unable to install Chromium inside a docker container on M1 macbook


I am Running docker on an M1 Macbook Pro , here i am using this docker script

FROM node:current-buster
# Create and set user
RUN wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
RUN apt-get update && apt install -y ./google-chrome-stable_current_amd64.deb

This throws an error google-chrome-stable:amd64 : Depends: libasound2:amd64 (>= 1.0.16) but it is not installable

and same for other dependencies

I have tried various ways:

  1. changing base image
  2. changing the installation step to
apt-get install -y wget gnupg ca-certificates procps libxss1 && 
wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add -      && sh -c 'echo "deb [arch=amd64] 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 

(This gives an error unable to locate package)

The script runs on a linux machine but for m1 mac it doesnt work.

I actually wanted to run puppeteer inside docker for which i am trying to install chrome incase there is an another way around.


Solution

  • docker buildx build --platform=linux/amd64
    

    This allows us to build the image atleast. Not sure if running it would produce the same result on M1 machine but atleast the image is built

    EDIT::

    so chrome has no arm image and that was the main cause for this problem changing it to chromium on base ubuntu 18.04 seems to work fine

    FROM ubuntu:18.04
    RUN apt-get install -y chromium-browser