5

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
  • Can you please update with your full Dockerfile? We need to know what the image is FROM.
    – cam
    Commented Feb 19, 2021 at 3:10

1 Answer 1

8

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

4
  • 2
    Thank you. I had this issue with an M1 Mac. I am guessing Docker defaults to 64-bit architecture by default. Commented Jan 20, 2022 at 19:50
  • 2
    Been searching for this solution for a long time, thank you for your help.
    – Sam
    Commented Jan 25, 2022 at 16:30
  • On rails, does this make the bundle install crash? It is happening to me when I try to build my ruby image
    – josegp
    Commented Feb 8, 2022 at 11:01
  • Sorry, I don’t work with Ruby. You might have some luck in the Docker slack group
    – Ryan
    Commented Feb 10, 2022 at 1:27

Not the answer you're looking for? Browse other questions tagged or ask your own question.