Unable to install r package inside docker container - r

I'm trying to install the docker package using binaries inside a docker container. inspired by this post:How to speed up R packages installation in docker
Now all the cran package to be installed is stored in file requirements-bin.txt
Error:
E: Unable to locate package r-cran-plumber
E: Unable to locate package r-cran-tolerance
Docker File:
FROM rocker/r-apt:bionic
WORKDIR /app
RUN apt-get update && \
apt-get install -y libxml2-dev
# Install binaries (see https://datawookie.netlify.com/blog/2019/01/docker-images-for-r-r-base-versus-r-apt/)
COPY ./requirements-bin.txt .
RUN cat requirements-bin.txt | xargs apt-get install -y -qq
# Clean up package registry
RUN rm -rf /var/lib/apt/lists/*
COPY ./src /app
EXPOSE 5000
CMD ["Rscript", "Server.R"]
requirements-bin.txt
r-cran-plumber
r-cran-tolerance

Related

Error Installing redux R package on centos7

Am getting an error trying to install redux r package on centos7, and have no idea how to fix it. Has anybody come across it before?
my Dockerfile is:
FROM centos:centos7
RUN yum -y install wget git tar
RUN yum -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
RUN yum -y install epel-release openssh-server
ENV R_VERSION=4.0.5
RUN wget https://cdn.rstudio.com/r/centos-7/pkgs/R-${R_VERSION}-1-1.x86_64.rpm \
&& yum -y install R-${R_VERSION}-1-1.x86_64.rpm \
&& rm R-${R_VERSION}-1-1.x86_64.rpm
ENV PATH="${PATH}:/opt/R/${R_VERSION}/bin/"
RUN yum -y install openssl-devel
RUN Rscript -e "install.packages(c('redux'), repos = 'https://packagemanager.rstudio.com/all/__linux__/centos7/latest')"
RUN Rscript -e "library(redux)"
CMD ["/bin/bash"]
Then i build the image:
docker build -t test-3:latest .
And the error i get is:
=> ERROR [8/8] RUN Rscript -e "library(redux)" 0.6s
------
> [8/8] RUN Rscript -e "library(redux)":
#12 0.528 Error: package or namespace load failed for 'redux' in dyn.load(file, DLLpath = DLLpath, ...):
#12 0.528 unable to load shared object '/opt/R/4.0.5/lib/R/library/redux/libs/redux.so':
#12 0.528 libhiredis.so.0.12: cannot open shared object file: No such file or directory
#12 0.528 Execution halted
------
executor failed running [/bin/sh -c Rscript -e "library(redux)"]: exit code: 1
ps. I am able to install any other package and reference it without problems
That file seems to come from the hiredis package: https://rhel.pkgs.org/7/okey-x86_64/hiredis-0.12.1-1.el7.centos.x86_64.rpm.html
Try adding the line RUN yum -y install hiredis or maybe adding that package to one of your existing yum install lines.
So turns out I had to also have hiredis installed for the package to load successfully
Updated dockerfile:
FROM centos:centos7
RUN yum -y install wget git tar
RUN yum -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
RUN yum -y install epel-release openssh-server
ENV R_VERSION=4.0.5
RUN wget https://cdn.rstudio.com/r/centos-7/pkgs/R-${R_VERSION}-1-1.x86_64.rpm \
&& yum -y install R-${R_VERSION}-1-1.x86_64.rpm \
&& rm R-${R_VERSION}-1-1.x86_64.rpm
ENV PATH="${PATH}:/opt/R/${R_VERSION}/bin/"
RUN yum -y install openssl-devel hiredis
RUN Rscript -e "install.packages(c('redux'), repos = 'https://packagemanager.rstudio.com/all/__linux__/centos7/latest')"
RUN Rscript -e "library(redux)"
CMD ["/bin/bash"]

cannot install devtools in r shiny docker

I'm trying to build a docker image for my shiny app. Below is my dockerfile. When I build my images, everything else seems fine, except I got error message Error in library(devtools) : there is no package called ‘devtools’ Execution halted. I also tried devtools::install_github('nik01010/dashboardthemes') with no success. I have non clue why? What could go wrong? Do anyone know what is wrong with my dockerfile? Thanks a lot.
# Install R version 3.6
FROM r-base:3.6.0
# Install Ubuntu packages
RUN apt-get update && apt-get install -y \
sudo \
gdebi-core \
pandoc \
pandoc-citeproc \
libcurl4-gnutls-dev \
libcairo2-dev/unstable \
libxt-dev \
libssl-dev
# Download and install ShinyServer (latest version)
RUN wget --no-verbose https://s3.amazonaws.com/rstudio-shiny-server-os-build/ubuntu-12.04/x86_64/VERSION -O "version.txt" && \
VERSION=$(cat version.txt) && \
wget --no-verbose "https://s3.amazonaws.com/rstudio-shiny-server-os-build/ubuntu-12.04/x86_64/shiny-server-$VERSION-amd64.deb" -O ss-latest.deb && \
gdebi -n ss-latest.deb && \
rm -f version.txt ss-latest.deb
# Install R packages that are required
RUN R -e "install.packages(c('devtools', 'shiny','shinythemes','shinydashboard','shinyWidgets','shinyjs', 'tidyverse', 'dplyr', 'ggplot2','rlang','DT','lubridate', 'plotly', 'leaflet', 'mapview', 'tigris', 'rgdal', 'visNetwork', 'wordcloud2', 'arules'), repos='http://cran.rstudio.com/')"
RUN R -e "library(devtools)"
RUN R -e "install_github('nik01010/dashboardthemes')"
# Copy configuration files into the Docker image
COPY shiny-server.conf /etc/shiny-server/shiny-server.conf
COPY /app /srv/shiny-server/
# Make the ShinyApp available at port 80
EXPOSE 80
# Copy further configuration files into the Docker image
COPY shiny-server.sh /usr/bin/shiny-server.sh
CMD ["/usr/bin/shiny-server.sh"]
There are a few approaches you might try.
Easiest:
Use remotes::install_github instead of devtools. remotes has many fewer dependencies if you don't need the other functionality.
Second Easiest:
Use rocker/tidyverse image from Docker Hub instead of baseR image.
docker pull rocker/tidyverse
Change line 2:
FROM rocker/verse
Hardest:
Otherwise, you will need to figure out which dependencies you need to install inside your docker image before you can install devtools. It will likely be obvious if you try to install it interactively.
Make sure the container is running
Get the container name using docker ps
Start a shell with docker exec -it <container name> /bin/bash
Start R and try to install devtools interactively

How to build Dockerfile with R & Java

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
However I get the following: installation of package ‘rJava’ had non-zero exit status.
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?
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
I'm new to docker and any help with this would be much appreciated.
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.
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')"
Note: liblzma-dev and libbz2-dev are additional system dependencies for compiling rJava.

jupyter lab (not pip installed but GitHub code) not loading icons when opened via docker

I am trying to load JupyterLab (by building the GitHub source code and not installing it using 'pip'), by opening it via a docker container, but it is not loading the icons which are accessed by css variables (e.g. :- background_image = var(--jp-terminal)). To be precise only the python icons for 'Notebook' and 'Console' are loading because they are loaded by html tags. The rest are loaded by variables as mentioned before.
My current directory looks like this :-
bin docker jupyterlab
The 'bin' folder contains the 'run.sh' file, the 'docker' folder contains the 'Dockerfile' and the 'jupyter lab' folder contains the source code and files for jupyter lab taken from GitHub.
Here is my Dockerfile :-
FROM centos:latest
RUN yum -y install epel-release \
yum -y install python-devel.x86_64 python27-python-devel.x86_64 gcc \
yum -y install nodejs \
yum -y install python-pip \
yum -y install sudo
RUN pip install --upgrade setuptools pip
RUN yum -y update
COPY jupyterlab /jupyterlab
RUN cd /jupyterlab && pip install -e . && jlpm install && jlpm run build && jlpm run build:core && jupyter lab build
COPY bin/run.sh /run.sh RUN chmod +x /run.sh
EXPOSE 8888
ENTRYPOINT ["/bin/sh", "/run.sh"]
Here is the 'run.sh' file which is used as entrypoint :-
jupyter notebook --generate-config
mkdir -p -m 700 /home/jupyter/.jupyter/ && echo "c.NotebookApp.token = ''" >> /home/jupyter/.jupyter/jupyter_notebook_config.py
jupyter lab --ip=* --no-browser --allow-root
Any suggestions?

Docker NPM Install Not working

I want to expose my asp.net core application in docker. However i can't get NPM to work. I tried the following below but i get the message that NPM is not found. However i installed nodejs, so i guess it should be available.
Any idea what i'm doing wrong ?
FROM microsoft/aspnet:1.0.0-rc1-update1-coreclr
ADD package.json /tmp/package.json
RUN printf "deb http://ftp.us.debian.org/debian jessie main\n" >> /etc/apt/sources.list
RUN apt-get -qq update && apt-get install -qqy sqlite3 libsqlite3-dev && rm -rf /var/lib/apt/lists/*
RUN apt-get update
RUN apt-get -y install nodejs && cd /tmp && npm install
COPY . /app
WORKDIR /app
RUN ["dnu", "restore"]
EXPOSE 5001/tcp
ENTRYPOINT ["dnx", "-p", "project.json", "web"]
Older versions of Node did not have npm bundled with them. On some Linux distributions, the version of Node in the repository is quite old e.g. on centos it is something like 0.10.7.
It is likely that your application requires a certain version of nodejs to be installed. If this is so, you will need to add the relevant repository to your virtual machine as part of the dockerfile before running
apt-get -y install nodejs
This link gives some details of how to do this on your distribution:
https://nodejs.org/en/download/package-manager/#debian-and-ubuntu-based-linux-distributions.
If on the other hand you are happy with whatever version of Node your distribution has in its repo, then Suresh Koya's answer is fine.
On linux npm has to be installed separate than nodejs.
You need to add:
RUN apt-get -y install npm
http://blog.teamtreehouse.com/install-node-js-npm-linux
As you can see here:
https://hub.docker.com/r/microsoft/aspnet/~/dockerfile/
FROM mono:4.0.1
mono:4.0.1:
FROM debian:wheezy
Why do you use the jessie ?
RUN printf "deb http://ftp.us.debian.org/debian jessie main\n" >> /etc/apt/sources.list
FROM microsoft/aspnet:1.0.0-rc1-update1-coreclr
ADD package.json /tmp/package.json
RUN printf "deb http://ftp.us.debian.org/debian jessie main\n" >> /etc/apt/sources.list
RUN apt-get -qq update && apt-get install -qqy sqlite3 libsqlite3-dev && \
apt-get -y install nodejs npm && cd /tmp && npm install && \
rm -rf /var/lib/apt/lists/*
COPY . /app
WORKDIR /app
RUN ["dnu", "restore"]
EXPOSE 5001/tcp
ENTRYPOINT ["dnx", "-p", "project.json", "web"]

Resources