我们如何使用dpkg在dockerfile中的高山图像上安装google-chrome-stable?

时间:2019-11-01 05:00:15

标签: docker docker-compose alpine

我正在尝试使用dpkg在高山图像上安装google-chrome-stable。但是,已经安装了dpkg,但没有安装google-chrome-stable,而是返回此错误?是否可以使用dpkg或其他方式在高山图像中安装google-chrome-stable?

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

1 个答案:

答案 0 :(得分:0)

要在Alpine Linux上安装Google Chrome,您只需使用Chromium(Alpine的软件包管理器)安装Alpine apk软件包,即可:

apk add chromium

尽管Alpine确实提供了dpkg,这对于出于特定目的安装轻量级Debian软件包很有用,但是您将无法将其用于安装复杂的Debian软件包,因为不可能满足许多​​Debian依赖性。 Alpine通常不兼容Debian(依靠musl libc),因此使用apk安装本机Alpine软件包是正确的方法。