DockerfileでOracle Java8をインストールする

開発 hironemuhironemu

Dockerを使ってJava8をインストールするときに一手間必要だったので、備忘録として残しておきます。

Oracle Java8をaptでインストールする際、ラインセンスの同意を求められる。

しかし、Dockerfileを使ってインストールするとき、この部分でエラーになってしまう。以下、エラー内容。

Do you accept the Oracle Binary Code license terms?
Use of uninitialized value $_[1] in join or string at /usr/share/perl5/Debconf/DbDriver/Stack.pm line 111.
user did not accept the oracle-license-v1-1 license
Use of uninitialized value $val in substitution (s///) at /usr/share/perl5/Debconf/Format/822.pm line 83, <GEN6> line 9.
Use of uninitialized value $val in concatenation (.) or string at /usr/share/perl5/Debconf/Format/822.pm line 84, <GEN6> line 9.
Declined "Oracle Binary Code License for Java"

If you do not agree to the license terms you cannot install this software.

The installation of this package will be canceled.

dpkg: error processing /var/cache/apt/archives/oracle-java8-installer_8u0-1~webupd8~5_all.deb (--unpack):
 subprocess new pre-installation script returned error exit status 1

Dockerfileを以下のようにすることでインストールすることができる。(Javaのインストール部分のみ抜粋)

RUN add-apt-repository ppa:webupd8team/java
RUN echo oracle-java8-installer shared/accepted-oracle-license-v1-1 select true | /usr/bin/debconf-set-selections
RUN apt-get update && apt-get clean
RUN apt-get install -y oracle-java8-installer
Tags: