1

I have been building a docker container for an R application and have continually run into an error with downloading a PDF report. The PDF report function works fine in R on a local machine, but when containerized, it throws the error below. I have tried forcing the install of specific packages, namely Knitr and Rmarkdown as other questions have mentioned, however it is still showing the same error. The file in Chrome downloads simply says "Failed - Server Problem". I have tested the download of a CSV file using the app, which works fine, therefore I believe it's an issue with generating and downloading a markdown PDF report.

I have included the build Dockerfile to assist. Any suggestions would be amazing!

Thanks!

DOCKERFILE:

FROM openanalytics/r-base

MAINTAINER ________

# system libraries of general use
RUN apt-get update && apt-get install -y \
    sudo \
    pandoc \
    pandoc-citeproc \
    libcurl4-gnutls-dev \
    libcairo2-dev \
    libxt-dev \
    libssl-dev \
    libssh2-1-dev \
    libxml2-dev \
    libssl1.0.0 \
    libpq-dev \
    git \
    texlive-full \
    html-xml-utils \
    libv8-3.14-dev

# system library dependency for the app

RUN apt-get update

# install packages for R

RUN R -e "install.packages(c('hms','devtools'), repos='https://cloud.r- 
project.org/')"

RUN R -e "require(devtools)"

RUN R -e "install.packages(c('car'), repos='https://cloud.r-project.org/')"

RUN R -e "devtools::install_version('readxl', version = '1.0.0', 
repos='https://cloud.r-project.org/')"
RUN R -e "devtools::install_version('DT', version = '0.2', 
repos='https://cloud.r-project.org/')"
RUN R -e "devtools::install_version('shinydashboard', version = '0.6.1', 
repos='https://cloud.r-project.org/')"
RUN R -e "devtools::install_version('knitr', version = '1.18', 
repos='https://cloud.r-project.org/')"
RUN R -e "devtools::install_version('magrittr', version = '1.5', 
repos='https://cloud.r-project.org/')"
RUN R -e "devtools::install_version('ggrepel', version = '0.7.0', 
repos='https://cloud.r-project.org/')"
RUN R -e "devtools::install_version('dplyr', version = '0.7.4', 
repos='https://cloud.r-project.org/')"
RUN R -e "devtools::install_version('Rcpp', version = '0.12.14', 
repos='https://cloud.r-project.org/')"
RUN R -e "devtools::install_version('rhandsontable', version = '0.3.4', 
repos='https://cloud.r-project.org/')"
RUN R -e "devtools::install_version('shinyjs', version = '0.9.1', 
repos='https://cloud.r-project.org/')"
RUN R -e "devtools::install_version('V8', version = '1.5', 
repos='https://cloud.r-project.org/')"
RUN R -e "devtools::install_version('data.table', version = '1.10.4-3', 
repos='https://cloud.r-project.org/')"
RUN R -e "devtools::install_version('packrat', version = '0.4.8-1', 
repos='https://cloud.r-project.org/')"
RUN R -e "devtools::install_version('zoo', version = '1.8-1', 
repos='https://cloud.r-project.org/')"
RUN R -e "install.packages('shiny', repos='https://cloud.r-project.org/')"
RUN wget https://github.com/rstudio/rmarkdown/archive/v1.8.tar.gz
RUN R CMD INSTALL v1.8.tar.gz
RUN R -e "install.packages('xml2', repos='https://cloud.r-project.org/')"
RUN R -e "install.packages('rvest', repos='https://cloud.r-project.org/')"
RUN wget https://cran.r- 
project.org/src/contrib/Archive/kableExtra/kableExtra_0.3.0.tar.gz
RUN R CMD INSTALL kableExtra_0.3.0.tar.gz

# copy the app to the image
RUN mkdir /root/tsk
COPY tsk /root/tsk

COPY Rprofile.site /usr/lib/R/etc/

EXPOSE 3838

CMD ["R", "-e", "shiny::runApp('/root/tsk')"]

ERROR FROM DOCKER:

Listening on http://0.0.0.0:3838
Warning in normalizePath(path, winslash = winslash, mustWork = mustWork) :
  path[1]="/tmp/RtmpMu8ezy/TSK.Rmd": No such file or directory
Warning: Error in tools::file_path_as_absolute: file '/tmp/RtmpMu8ezy/TSK.Rmd' 
does not exist
  [No stack trace available]
Warning in normalizePath(path, winslash = winslash, mustWork = mustWork) :
  path[1]="/tmp/RtmpMu8ezy/TSK.Rmd": No such file or directory
Warning: Error in tools::file_path_as_absolute: file '/tmp/RtmpMu8ezy/TSK.Rmd' 
does not exist
  [No stack trace available]
Warning in normalizePath(path, winslash = winslash, mustWork = mustWork) :
  path[1]="/tmp/RtmpMu8ezy/TSK.Rmd": No such file or directory
Warning: Error in tools::file_path_as_absolute: file '/tmp/RtmpMu8ezy/TSK.Rmd' 
does not exist
  [No stack trace available]
MagicPossum
  • 251
  • 5
  • 16
  • It's not clear to me where `TSK.Rmd` comes from. Is that in one of the packages you're installing? – r2evans Nov 04 '18 at 07:20
  • Hi r2evans, thanks for the reply. The TSK.Rmd is the R markdown table that is used to render the PDF. It is contained in the folder where all the R project files are located. The docker container should have this file inside the container. At least that's what I think. – MagicPossum Nov 04 '18 at 08:13
  • Ok, but the only `Dockerfile` line that could be close is `COPY tsk /root/tsk` which is not `/tmp/Rtmp.../TSK.Rmd`. I just cannot reproduce this as-is. (BTW: never use `require(pkgname)` unless you check the return value and do something with that knowledge; use `library(pkgname)` if you don't plan on checking to see if `require` returned `TRUE`. https://stackoverflow.com/a/51263513/3358272) – r2evans Nov 04 '18 at 08:17
  • might be problem with PNADOC...can u check in the community? – sai saran Nov 04 '18 at 08:55
  • Hi r2evans, thanks for the tip on require/library, will update my dockerfile. I've managed to solve the problem! It was simply changing the filename CASE from tsk.Rmd to TSK.Rmd - reason for this is that testing was always on OSX in an IDE which didn't throw any errors, however when building a container with Ubuntu which is case sensitive, it was unable to find the markdown file.. All fixed :) – MagicPossum Nov 05 '18 at 09:41

1 Answers1

2

Simply changing the filename CASE from tsk.Rmd to TSK.Rmd - reason for this is that testing was always on OSX in an IDE which didn't throw any errors, however when building a container with Ubuntu which is case sensitive, it was unable to find the markdown file.

When building with different operating systems, be sure to check if the system is case sensitive! An easy mistake!

MagicPossum
  • 251
  • 5
  • 16