在自定义 JupyterHub 用户笔记本图像中包含额外的 R pkg?

Include additional R pkg in custom JupyterHub user notebook image?

我自定义用户笔记本环境 like so(安装自定义 python 包)

FROM jupyter/minimal-notebook:177037d09156
# Get the latest image tag at:
# https://hub.docker.com/r/jupyter/minimal-notebook/tags/
# Inspect the Dockerfile at:
# https://github.com/jupyter/docker-stacks/tree/master/minimal-notebook/Dockerfile

# install additional package...
RUN pip install --no-cache-dir astropy

如何安装自定义 R 包?具体来说,我要安装:

这些在 CRAN 中可用

如果你想使用 R 包和 jupyter notebook,我建议使用 jupyter/r-notebook 作为基础镜像。之后要安装 R 包,请使用 conda.

安装它们
FROM jupyter/r-notebook
RUN conda install --yes \
        r-reticulate r-mvtnorm r-gdata r-matrixcalc \
        r-gtools r-mpoly r-moments \
    && conda clean --all --yes

我能够安装它(使用 jupyter/minimal-notebook 作为基础映像而不是 jupyter/r-notebook),就像这样:

FROM jupyter/minimal-notebook:177037d09156
# Get the latest image tag at:
# https://hub.docker.com/r/jupyter/minimal-notebook/tags/
# Inspect the Dockerfile at:
# https://github.com/jupyter/docker-stacks/tree/master/minimal-notebook/Dockerfile

RUN R -e 'install.packages("gtools", repos = "http://cran.us.r-project.org")'
RUN R -e 'install.packages("gdata", repos = "http://cran.us.r-project.org")'
RUN R -e 'install.packages("reticulate", repos = "http://cran.us.r-project.org")'
RUN R -e 'install.packages("matrixcalc", repos = "http://cran.us.r-project.org")'