如何在ubuntu docker映像中静默安装r-base

问题描述 投票:1回答:1

我需要在ubuntu:18.04 dockerimage中安装r-base。我在通过

建立图像时正在执行此操作
RUN apt-get update; apt-get install -y r-base [many other packages]

以及许多其他软件包安装。问题是,在安装过程结束时设置r-base时,它要求用户输入时区,然后输入指定时区内的city。我显然在构建容器时无法输入数据。无论如何,我如何设法安装r-base?

r dockerfile ubuntu-18.04 silent silent-installer
1个回答
-1
投票

直接取自:https://github.com/rocker-org/rocker/blob/master/r-ubuntu/Dockerfile

FROM ubuntu:bionic

LABEL org.label-schema.license="GPL-2.0" \
      org.label-schema.vcs-url="https://github.com/rocker-org/r-apt" \
      org.label-schema.vendor="Rocker Project" \
      maintainer="Dirk Eddelbuettel <[email protected]>"

## Set a default user. Available via runtime flag `--user docker` 
## Add user to 'staff' group, granting them write privileges to /usr/local/lib/R/site.library
## User should also have & own a home directory (for rstudio or linked volumes to work properly). 
RUN useradd docker \
    && mkdir /home/docker \
    && chown docker:docker /home/docker \
    && addgroup docker staff

RUN apt-get update \
    && apt-get install -y --no-install-recommends \
        software-properties-common \
                ed \
        less \
        locales \
        vim-tiny \
        wget \
        ca-certificates \
        && add-apt-repository --enable-source --yes "ppa:marutter/rrutter3.5" \
    && add-apt-repository --enable-source --yes "ppa:marutter/c2d4u3.5" 

## Configure default locale, see https://github.com/rocker-org/rocker/issues/19
RUN echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen \
    && locale-gen en_US.utf8 \
    && /usr/sbin/update-locale LANG=en_US.UTF-8

ENV LC_ALL en_US.UTF-8
ENV LANG en_US.UTF-8

## This was not needed before but we need it now
ENV DEBIAN_FRONTEND noninteractive

# Now install R and littler, and create a link for littler in /usr/local/bin
# Default CRAN repo is now set by R itself, and littler knows about it too
# r-cran-docopt is not currently in c2d4u so we install from source
RUN apt-get update \
        && apt-get install -y --no-install-recommends \
                 littler \
         r-base \
         r-base-dev \
         r-recommended \
    && ln -s /usr/lib/R/site-library/littler/examples/install.r /usr/local/bin/install.r \
    && ln -s /usr/lib/R/site-library/littler/examples/install2.r /usr/local/bin/install2.r \
    && ln -s /usr/lib/R/site-library/littler/examples/installGithub.r /usr/local/bin/installGithub.r \
    && ln -s /usr/lib/R/site-library/littler/examples/testInstalled.r /usr/local/bin/testInstalled.r \
    && install.r docopt \
    && rm -rf /tmp/downloaded_packages/ /tmp/*.rds \
    && rm -rf /var/lib/apt/lists/*

CMD ["bash"]
© www.soinside.com 2019 - 2024. All rights reserved.