Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can we install google-chrome-stable on alpine image in dockerfile using dpkg?

Tags:

I am trying to install google-chrome-stable on alpine image using dpkg. However, the dpkg is installed but it does not install google-chrome-stable and return this error instead? Is there a way to install google-chrome-stable in alpine image either using dpkg or other way?

dpkg: regarding google-chrome-stable_current_amd64.deb containing   google-chrome-stable:amd64, pre-dependency problem:  google-chrome-stable:amd64 pre-depends on dpkg (>= 1.14.0)  dpkg: error processing archive google-chrome-stable_current_amd64.deb (--install):  pre-dependency problem - not installing google-chrome-stable:amd64 Errors were encountered while processing: 

Dockerfile:

# Base image FROM ruby:2.6.3-alpine3.10 # Use node version 10.16.3, yarn version 1.16.0 RUN apk add  --no-cache --repository http://dl-cdn.alpinelinux.org/alpine/v3.10/main/ nodejs=10.16.3-r0 RUN apk add  --no-cache --repository http://dl-cdn.alpinelinux.org/alpine/v3.10/community/ yarn=1.16.0-r0  # Install dependencies RUN apk upgrade RUN apk --update \     add build-base \     git \     tzdata \     nodejs \     nodejs-npm \     bash \     curl \     yarn \     gzip \     postgresql-client \     postgresql-dev \     imagemagick \     imagemagick-dev \     imagemagick-libs \     chromium \     chromium-chromedriver \     ncurses \     less \     dpkg=1.19.7-r0 \     chromium \     chromium-chromedriver  RUN dpkg --add-architecture amd64 RUN wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb RUN dpkg -i google-chrome-stable_current_amd64.deb  # This is the base directory used in any # further COPY, RUN and ENTRYPOINT commands WORKDIR /webapp # Copy Gemfile and Gemfile.lock and run bundle install COPY Gemfile* /webapp/ RUN gem install bundler -v '1.17.3' && \     bundle _1.17.3_ install  # Copy everything to /webapp for docker image COPY . ./  EXPOSE 3000  # Run the application CMD ["rails", "server", "-b", "0.0.0.0"] 
like image 975
Code father Avatar asked Nov 01 '19 05:11

Code father


People also ask

Can you run Chrome in Docker?

Without the display variable we can't run GUI apps inside a container. Now chrome runs inside the container, as we had mentioned DISPLAY variable while launching this container!

What is the difference between Chrome and Chromium?

Chromium is an open-source and free web browser that is managed by the Chromium Project. In comparison, Google Chrome is a proprietary browser developed and managed by Google. Unlike Chromium, Google Chrome offers built-in support for media codecs like MP3, H. 264, and AAC, as well as Adobe Flash.


1 Answers

Installing the Chrome .deb file this way won't work on Alpine.

While the dpkg package is available in the Alpine repository, and is useful for installing lightweight Debian packages, you won't be able to use it for installing complex Debian packages, since it'll be impossible to satisfy many Debian dependencies. Alpine is generally not Debian compatible (relying on musl libc), so installing native Alpine packages using apk is the right way to go.

AFAIK, there's currently no Google Chrome Alpine Linux compatible, musl-libc build.

You could, however, install the Chromium browser, which is available using an apk package:

apk add chromium

Another option is enabling glibc on a vanilla Alpine image, making it compatible with Debian binaries. This is a fairly simple procedure, see: Dockerfile. However, it may not be suitable for images with existing applications such as ruby:2.6.3-alpine3.10. Moreover, even with a glibc setup on Alpine, Chrome is not likely to run without issues. I have made a quick attempt (Dockerfile) but couldn't get past the first segfault.

Edit 9/5/21: Running the debian compatible Chrome stable on Alpine is going to be a very difficult task to say the least. This is in part due to the very large number of dependencies and libraries. Trying to run it results with segfaults during dynamic linking and finally assertions from the dynamic linker. Even if we manage to get passed these issues and start Chrome it will probably be very unstable.

like image 183
valiano Avatar answered Sep 28 '22 02:09

valiano