如何使用R&构建Dockerfile爪哇 [英] How to build Dockerfile with R & Java
问题描述
我正在尝试构建一个使用RJava包运行R的Docker容器.我尝试了以下代码:
I'm trying to build a Docker container that runs R with the package RJava. I have tried the following code:
# Install R version 3.6.3
FROM rocker/tidyverse:3.6.3
# Make ~/.R
RUN mkdir -p $HOME/.R
# Install Ubuntu packages && then R packages
RUN install2.r --error \
lubridate magrittr RPostgres DBI broom rlang rJava
但是我得到以下信息:软件包"rJava"的安装退出状态为非零.
However I get the following: installation of package ‘rJava’ had non-zero exit status.
任何人都可以帮我这个忙.我在想这也许是因为未安装Java.有谁知道如何在此docker容器上安装Java?
Can anyone help me with this. I'm thinking that maybe it is because Java is not installed. Does anyone know how to install Java on this docker container?
我尝试按照我发现的另一篇文章将以下内容添加到我的dockerfile中,但是出现错误消息存储库' http://ppa.launchpad.net/webupd8team/java/ubuntu focus Release'没有发布文件:
I've tried adding the following to my dockerfile as per another post I found however I get the error saying 'The repository 'http://ppa.launchpad.net/webupd8team/java/ubuntu focal Release' does not have a Release file:
# Install "software-properties-common" (for the "add-apt-repository")
RUN apt-get update && apt-get install -y \
software-properties-common
# Add the "JAVA" ppa
RUN add-apt-repository -y \
ppa:webupd8team/java
# Install OpenJDK-8
RUN apt-get update && \
apt-get install -y openjdk-8-jdk && \
apt-get install -y ant && \
apt-get clean;
# Fix certificate issues
RUN apt-get update && \
apt-get install ca-certificates-java && \
apt-get clean && \
update-ca-certificates -f;
# Setup JAVA_HOME -- useful for docker commandline
ENV JAVA_HOME /usr/lib/jvm/java-8-openjdk-amd64/
RUN export JAVA_HOME
我是Docker的新手,在此方面提供的任何帮助将不胜感激.
I'm new to docker and any help with this would be much appreciated.
推荐答案
rocker
图像基于 debian
,而不是 ubuntu
.具体来说,它是 Debian GNU/Linux 10(破坏者)
.在该版本中,您可以通过 apt
安装软件包 openjdk-11-jdk
来安装 java
,而无需添加任何存储库用于 openjdk-8-jdk
.
The rocker
images are based on debian
, not ubuntu
. Specifically it is Debian GNU/Linux 10 (buster)
. With that version, you can install java
by installing the package openjdk-11-jdk
via apt
and you don't need to add any repositories for openjdk-8-jdk
.
因此,一个可以正常工作的dockerfile会安装 rJava
:
So a working dockerfile that installs rJava
:
FROM rocker/tidyverse:3.6.3
RUN apt-get update && \
apt-get install -y openjdk-11-jdk && \
apt-get install -y liblzma-dev && \
apt-get install -y libbz2-dev
RUN Rscript -e "install.packages('rJava')"
注意: liblzma-dev
和 libbz2-dev
是用于编译 rJava
的其他系统依赖项.
Note: liblzma-dev
and libbz2-dev
are additional system dependencies for compiling rJava
.
这篇关于如何使用R&构建Dockerfile爪哇的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!