2

I'm trying to create a Dockerfile for running R on a raspberry pi3. I found a container that has Debian for the pi. I also found a docker file that does what I want for an x86 computer. I thought creating a dockerfile for the pi would be a simple as changing the base image and the repo to install R for arm. This is my Dockerfile:

FROM resin/raspberry-pi3-debian
LABEL maintainer="Me <my@email.com>"

## 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 \
        ed \
        less \
        locales \
        vim-tiny \
        wget \
        ca-certificates \
        fonts-texgyre \
    && rm -rf /var/lib/apt/lists/*

## 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

## Use Debian unstable via pinning -- new style via APT::Default-Release
RUN echo "deb http://cran.rstudio.com/bin/linux/debian jessie-cran3/" > /etc/apt/sources.list.d/debian-unstable.list \
    && echo 'APT::Default-Release "testing";' > /etc/apt/apt.conf.d/default

ENV R_BASE_VERSION 3.4.4

## Now install R and littler, and create a link for littler in /usr/local/bin
## Also set a default CRAN repo, and make sure littler knows about it too
RUN apt-get update \
    && apt-get install -t unstable -y --no-install-recommends \
        littler \
                r-cran-littler \
        r-base=${R_BASE_VERSION}* \
        r-base-dev=${R_BASE_VERSION}* \
        r-recommended=${R_BASE_VERSION}* \
        && echo 'options(repos = c(CRAN = "https://cloud.r-project.org/"), download.file.method = "libcurl")' >> /etc/R/Rprofi$
        && echo 'source("/etc/R/Rprofile.site")' >> /etc/littler.r \
    && ln -s /usr/share/doc/littler/examples/install.r /usr/local/bin/install.r \
    && ln -s /usr/share/doc/littler/examples/install2.r /usr/local/bin/install2.r \
    && ln -s /usr/share/doc/littler/examples/installGithub.r /usr/local/bin/installGithub.r \
    && ln -s /usr/share/doc/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 ["R"]

Alas, this did not work

docker build --tag hello .

Get:18 http://deb.debian.org jessie/main armhf Packages [8,864 kB]
Fetched 23.6 MB in 30s (775 kB/s)
Reading package lists...
W: GPG error: http://cran.rstudio.com jessie-cran3/ Release: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 06F90DE5381BA480
Reading package lists...
E: The value 'unstable' is invalid for APT::Default-Release as such a release is not available in the sources
The command '/bin/sh -c apt-get update     && apt-get install -t unstable -y --no-install-recommends         littler                 r-cran-littler         r-base=${R_BASE_VERSION}*         r-base-dev=${R_BASE_VERSION}*         r-recommended=${R_BASE_VERSION}*         && echo 'options(repos = c(CRAN = "https://cloud.r-project.org/"), download.file.method = "libcurl")' >> /etc/R/Rprofile.site         && echo 'source("/etc/R/Rprofile.site")' >> /etc/littler.r     && ln -s /usr/share/doc/littler/examples/install.r /usr/local/bin/install.r     && ln -s /usr/share/doc/littler/examples/install2.r /usr/local/bin/install2.r     && ln -s /usr/share/doc/littler/examples/installGithub.r /usr/local/bin/installGithub.r     && ln -s /usr/share/doc/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/*' returned a non-zero code: 100

My guess is that this line is wrong

## Use Debian unstable via pinning -- new style via APT::Default-Release
RUN echo "deb http://cran.rstudio.com/bin/linux/debian jessie-cran3/" > /etc/apt/sources.list.d/debian-unstable.list \
    && echo 'APT::Default-Release "testing";' > /etc/apt/apt.conf.d/default

Alas, no clue how to fix it. Any suggestions?

3

Here is a stripped down Dockerfile that runs R 3.5 for a Raspberry Pi 3 B+:

# parent image
FROM resin/raspberrypi3-debian:latest

ENTRYPOINT []

# enable systemd
ENV INITSYSTEM on

# update sources
RUN echo "deb http://mirrordirector.raspbian.org/raspbian/ buster main" > /etc/apt/sources.list


# install R
RUN apt-get update && apt-get install -y \ 
  r-base \ 
  r-base-core \
  r-base-dev


# Run R
CMD ["R"]

You can see the current version of R available in the Debian package manager here: https://packages.debian.org/buster/r-base.

1

For a newer version of R, try using the backports CRAN archive for Debian Stretch:

# set up CRAN package repository for R 3.5 backports to Debian stretch
echo 'deb [arch=armhf] http://cran.rstudio.com/bin/linux/debian stretch-cran35/' > /etc/apt/sources.list.d/cran35.list
# import package repository key
sudo apt-key adv --keyserver keys.gnupg.net --recv-key 'E19F5F87128899B192B1A2C2AD5F960A256A04AF'

There is also a similar repository for version 3.4 - just replace 35 with 34 above. See also the information related to backports at https://cran.r-project.org/bin/linux/debian/#backports-on-cran. You can see which packages are there at http://cran.rstudio.com/bin/linux/debian/stretch-cran35/.

0

This works:

FROM resin/raspberry-pi3-debian
LABEL maintainer="Me <my@email.com>"

## 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 \
        ed \
        less \
        locales \
        vim-tiny \
        wget \
        ca-certificates \
        fonts-texgyre \
    && rm -rf /var/lib/apt/lists/*

## 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

## Use Debian unstable via pinning -- new style via APT::Default-Release
## RUN echo "deb http://cran.rstudio.com/bin/linux/debian jessie-cran3/" > /etc/apt/sources.list.d/debian-unstable.list 
## RUN apt-key adv --keyserver keys.gnupg.net --recv-key  06F90DE5381BA480


## Now install R and littler, and create a link for littler in /usr/local/bin
## Also set a default CRAN repo, and make sure littler knows about it too
RUN apt-get update \
    && apt-get install  -y --no-install-recommends \
        r-base \
        r-base-dev \
        r-recommended \
        && echo 'options(repos = c(CRAN = "https://cloud.r-project.org/"), download.file.method = "libcurl")' >> /etc/R/Rprofil
e.site \
    && rm -rf /tmp/downloaded_packages/ /tmp/*.rds \
    && rm -rf /var/lib/apt/lists/*

CMD ["R"]

Alas, I get an old version of R.

docker run -ti --rm imrpi3

R version 3.1.1 (2014-07-10) -- "Sock it to Me"
Copyright (C) 2014 The R Foundation for Statistical Computing
Platform: arm-unknown-linux-gnueabihf (32-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

  Natural language support but running in an English locale

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

Any suggestions for how to get a newer version?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.