16
13

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Debian に Google Chrome をインストール

Last updated at Posted at 2018-10-25

Anaconda の公式 Docker イメージ (Debian ベース1) に Google Chrome をインストールしようとしたところ、Ubuntu と同じやり方ではできずに手こずったのでメモ。

$ wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
$ sudo apt install ./google-chrome-stable_current_amd64.deb

dpkg -i の時点では「依存パッケージが入ってない」と怒られるが、その後 apt --fix-broken install で依存パッケージがインストールされる。
[追記] apt install ./foobar.deb で依存パッケージも含めてインストールできる、とご指摘いただいたので修正。

Google Chrome はブラウザなだけあって依存モジュールが多く、インストールにかなり時間がかかる。

Dockerfile の例

Anaconda 3 ベースで、Python から Selenium + Chrome Driver を扱えるようにする Dockerfile はこんな感じで書ける。

Dockerfile
FROM continuumio/anaconda3

RUN apt update \
  && apt install -y gnupg \
  && wget -q -O - https://dl.google.com/linux/linux_signing_key.pub | apt-key add - \
  && wget -q https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb \
  && apt install -y ./google-chrome-stable_current_amd64.deb \
  && apt clean \
  && rm -rf /var/lib/apt/lists/ \
  && rm google-chrome-stable_current_amd64.deb

RUN pip install selenium chromedriver-binary~=$(/usr/bin/google-chrome --version | perl -pe 's/([^0-9]+)([0-9]+\.[0-9]+).+/$2/g')
  • Docker コンテナ内で Google Chrome を起動する際は、ユーザが root だとそのままでは起動できないので --no-sandbox オプションを付ける必要がある。
  • Google Chrome と chromedriver-binary はメジャーバージョンを合わせる必要があるので、chromedriver-binary をインストールする際にバージョン指定をしている。 2
  1. https://github.com/ContinuumIO/docker-images/blob/master/anaconda3/Dockerfile#L1

  2. ChromeとPythonのchromedriver-binaryのバージョンを合わせたい。 - Qiita

16
13
4

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
16
13

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?