Install google-chrome-stable with docker

Viewed 1895

I get an error when I do docker-compose build.

I am using apple siilcon and I was able to build it with intel without any problems. Does anyone know if something is wrong?

Contents of docker

    RUN apt-get update && apt-get install -y unzip && \
    CHROME_DRIVER_VERSION=`curl -sS chromedriver.storage.googleapis.com/LATEST_RELEASE` && \
    wget -N http://chromedriver.storage.googleapis.com/$CHROME_DRIVER_VERSION/chromedriver_linux64.zip -P ~/ && \
    unzip ~/chromedriver_linux64.zip -d ~/ && \
    rm ~/chromedriver_linux64.zip && \
    chown root:root ~/chromedriver && \
    chmod 755 ~/chromedriver && \
    mv ~/chromedriver /usr/bin/chromedriver && \
    sh -c '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-chrome.list'
    RUN apt-get update
    RUN apt-get install -y google-chrome-stable

Error

 => ERROR [ 5/15] RUN apt-get install -y google-chrome-stable                                                                                                                                                                                                                                                3.2s
------                                                                                                                                                                                                                                                                                                            
 > [ 5/15] RUN apt-get install -y google-chrome-stable:                                                                                                                                                                                                                                                           
#8 1.090 Reading package lists...                                                                                                                                                                                                                                                                                 
#8 2.038 Building dependency tree...                                                                                                                                                                                                                                                                              
#8 2.154 Reading state information...                                                                                                                                                                                                                                                                             
#8 2.214 E: Unable to locate package google-chrome-stable
1 Answers

You can add the platform flag to the FROM statement in your Dockerfile. This will ensure the docker container builds the correct architecture every time.

I used this for Debian Linux and Chrome headless:

FROM --platform=linux/amd64 python:3.9

Related