DEV Community

Ajeet Singh Raina for Docker

Posted on

14 2 2

Unable to locate package google-chrome-stable

If you try to build a containerised Web scraping tool using Python, Selenium and Beautiful Soup on Apple M1 Pro, you might encounter the following issue while building the Dockerfile:

=> [ 3/11] COPY . /app                                                                                                  0.0s
 => [ 4/11] RUN wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add -                       0.9s
 => [ 5/11] RUN sh -c 'echo "deb http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.  0.2s
 => ERROR [ 6/11] RUN apt-get update -qqy --no-install-recommends && apt-get install -qqy --no-install-recommends googl  3.6s
------
 > [ 6/11] RUN apt-get update -qqy --no-install-recommends && apt-get install -qqy --no-install-recommends google-chrome-stable:
#10 3.592 E: Unable to locate package google-chrome-stable
------
executor failed running [/bin/sh -c apt-get update -qqy --no-install-recommends && apt-get install -qqy --no-install-recommends google-chrome-stable]: exit code: 100
Enter fullscreen mode Exit fullscreen mode

Assuming that you are using the traditional Dockerfile that reads:

FROM python:3.9

ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1


RUN wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add -
RUN sh -c 'echo "deb http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list'
RUN apt-get update -qqy --no-install-recommends && apt-get install -qqy --no-install-recommends google-chrome-stable

RUN pip install --no-cache-dir --upgrade pip
WORKDIR /app
COPY ./requirements.txt /app/requirements.txt
RUN pip3 install --no-cache-dir -r requirements.txt
COPY . .
CMD tail -f /dev/null
CMD python3 scraper.py
Enter fullscreen mode Exit fullscreen mode

To fix this issue, just modify the first line of the Dockerfile and add --platform=linux/amd64 entry.

FROM --platform=linux/amd64  python:3.9
Enter fullscreen mode Exit fullscreen mode

Now you should be able to build the Docker image successfully

docker build -t ajeetraina/scraperhubb .
[+] Building 160.4s (16/16) FINISHED                                                                                          
 => [internal] load build definition from Dockerfile                                                                     0.0s
 => => transferring dockerfile: 941B                                                                                     0.0s
 => [internal] load .dockerignore                                                                                        0.0s
 => => transferring context: 2B                                                                                          0.0s
 => [internal] load metadata for docker.io/library/python:3.9                                                            1.0s
 => CACHED [ 1/11] FROM docker.io/library/python:3.9@sha256:c1613835d7be322f98603f356b9e0c9d40f9589e94dc9f710e714a807a6  0.0s
 => [internal] load build context                                                                                        0.0s
 => => transferring context: 3.06kB                                                                                      0.0s
 => [ 2/11] WORKDIR /app                                                                                                 0.0s
 => [ 3/11] COPY . /app                                                                                                  0.0s
 => [ 4/11] RUN wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add -                       9.0s
 => [ 5/11] RUN sh -c 'echo "deb http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.  0.3s
 => [ 6/11] RUN apt-get update -qqy --no-install-recommends && apt-get install -qqy --no-install-recommends google-chr  82.9s 
 => [ 7/11] RUN apt-get install -yqq unzip                                                                               4.7s 
 => [ 8/11] RUN wget -O /tmp/chromedriver.zip http://chromedriver.storage.googleapis.com/`curl -sS chromedriver.storage  2.4s 
 => [ 9/11] RUN unzip /tmp/chromedriver.zip chromedriver -d /usr/local/bin/                                              0.5s 
 => [10/11] RUN pip install --upgrade pip                                                                               21.3s 
 => [11/11] RUN pip install -r /app/requirements.txt                                                                    37.0s 
 => exporting to image                                                                                                   1.2s 
 => => exporting layers                                                                                                  1.2s 
 => => writing image sha256:c5d84ecd6d74e35175816f4d7c248c3ff58fd063fe736bf157683a9cef4cea25                             0.0s 
 => => naming to docker.io/ajeetraina/scraperhubb                                                                        0.0s 

Use 'docker scan' to run Snyk tests against images to find vulnerabilities and learn how to fix them
Enter fullscreen mode Exit fullscreen mode

AWS GenAI LIVE image

Real challenges. Real solutions. Real talk.

From technical discussions to philosophical debates, AWS and AWS Partners examine the impact and evolution of gen AI.

Learn more

Top comments (2)

Collapse
 
enriquezarate profile image
Enrique Zárate

So simple! Thanks

Collapse
 
mominababar1 profile image
Momina Babar

It worked! Thanks

Qodo Takeover

Introducing Qodo Gen 1.0: Transform Your Workflow with Agentic AI

Rather than just generating snippets, our agents understand your entire project context, can make decisions, use tools, and carry out tasks autonomously.

Read full post

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay