我们如何使用 dpkg 在 dockerfile 中的 alpine 图像上安装 google-chrome-stable? [英] How can we install google-chrome-stable on alpine image in dockerfile using dpkg?

查看:107
本文介绍了我们如何使用 dpkg 在 dockerfile 中的 alpine 图像上安装 google-chrome-stable?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 dpkg 在 alpine 图像上安装 google-chrome-stable.但是,已安装 dpkg 但未安装 google-chrome-stable 并返回此错误?有没有办法使用 dpkg 或其他方式在 alpine 图像中安装 google-chrome-stable?

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:

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"]

推荐答案

以这种方式安装 Chrome .deb 文件在 Alpine 上不起作用.

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

虽然dpkg软件包在 Alpine 存储库中可用,对于安装轻量级 Debian 软件包很有用,您将无法使用它来安装复杂的 Debian 软件包,因为它无法满足许多 Debian 依赖项.Alpine 通常与 Debian 不兼容(依赖于 musl libc),因此使用 apk 安装本机 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,目前没有与 Google Chrome Alpine Linux 兼容的 musl-libc 构建.

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

但是,您可以安装 Chromium 浏览器,可使用 apk 包获得:

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

apk 添加铬

另一个选项是在 vanilla Alpine 映像上启用 glibc,使其与 Debian 二进制文件兼容.这是一个相当简单的过程,请参阅:Dockerfile.但是,它可能不适合具有现有应用程序的图像,例如 ruby:2.6.3-alpine3.10.此外,即使在 Alpine 上安装了 glibc,Chrome 也不太可能毫无问题地运行.我已经做了一个快速的尝试(Dockerfile)但不能不要越过第一个段错误.

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.

编辑 9/5/21:至少可以说,在 Alpine 上运行与 debian 兼容的 Chrome 稳定版将是一项非常艰巨的任务.这部分是由于依赖项和库的数量非常多.在动态链接期间尝试运行它会导致段错误,最终来自动态链接器的断言.即使我们设法解决了这些问题并启动了 Chrome,它也可能非常不稳定.

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.

这篇关于我们如何使用 dpkg 在 dockerfile 中的 alpine 图像上安装 google-chrome-stable?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆