Unable to install Chromium inside a docker container on M1 macbook
Asked Answered
W

3

22

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.

Warford answered 27/6, 2021 at 16:3 Comment(3)
Well, I'm facing the same problem with two libraries, And have no clue what to do.Beanpole
@mohammad.kaab which libraries i have figured out some ways to actually make this work infact the workaround for this is nothing but installing chromium which is available for arm and seems to work perfectly fineWarford
Thanks, I have solved the problem by changing the version of docker-compose file to 3 and add platform: linux/x86_64 to the service. I actually had a problem with running the docker composer file.Beanpole
W
22
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
Warford answered 30/6, 2021 at 12:22 Comment(5)
Note that OP was on Debian. Pretty sure it is just chromium now and not chromium-browser now. See packages.debian.org/search?keywords=chromiumLyndsaylyndsey
well, now working for me, I tried above Dockerfile with command docker buildx build --platform=linux/amd64 -t my_image . on Mac with M1 and on line RUN apt-get install -y chromium-browser occurs error Package 'chromium-browser' has no installation candidate. BTW chromium doest work tooFurnishings
RUN apt-get install -y chromium-browser produces exactly error Package chromium-browser is not available, but is referred to by another package. as in #47204312Pyrolysis
I'm still getting the same error. I want to run pyppeteer in airflow so I'm using apache/airflow:2.6.0 as a base image and running into this problemChalcis
I'm still getting the same error as well. This solution does not work for me. Has anyone solved this?Respiration
B
0

For my case, in Dockerfile, changing from

FROM python:3.11-slim

to

FROM --platform=linux/amd64 python:3.11-slim

solved my issue. Depending on the image you are using you can add --platfrom=linux/amd64 option and give it a try.

https://docs.docker.com/build/guide/multi-platform/

I hope it helps

Burget answered 20/6 at 11:18 Comment(0)
D
-2

It should work on both debian and ubuntu, try first to run sudo apt update after that it was able to install arm build of chromium.

Delightful answered 16/2, 2023 at 14:48 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.