DEV Community

Ajeet Singh Raina for Docker

Posted on

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

Top comments (0)