Docker image is rebuilt when starting for the first time

I guess I’m really missing something in the setup.

Because, when I open my app for the first time in ShinyProxy (web interface), I can see in the logs (docker logs -f), that the image is rebuilt completely. This takes about 5 minutes - so nothing a user would wait for.

However, I did run docker build -t openanalytics/shinyproxy-template . in the folder of my own app before starting ShinyProxy.

Any idea what I’m doing wrong or what I can check?

Confused. Why not docker pull openanalytics/shinyproxy-template?

Thanks for the reply. Why should I do that? Anyway, I tried and got the following response:

$ docker pull openanalytics/shinyproxy-template
Using default tag: latest
Error response from daemon: pull access denied for openanalytics/shinyproxy-template, repository does not exist or may require 'docker login'

Sorry I mean you may try docker pull openanalytics/shinyproxy-demo

The reason why docker build the image is it can’t find the image. Please use docker images to see the existing images and ensure the image name used in application.yml can be found.

Anyway, what I mean is if you are trying to create an image of your own, I think you should change the name openanalytics/shinyproxy-template to something like myimage

Thanks again for helping me out here. I’m quite new to docker.

However, the images seem to be available:

$ docker images
REPOSITORY                          TAG                 IMAGE ID            CREATED             SIZE
my/app                              latest              1d433dd30d17        12 minutes ago      955MB
openanalytics/shinyproxy-template   latest              5b3c7998dc41        17 hours ago        955MB

As you can see, I built the image using another name (my/app). And verified, that it is used by ShinyProxy:

$ docker ps
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                     NAMES
e2aa1d1bc447        my/app              "R -e shiny::runApp(…"   4 minutes ago       Up 4 minutes>3838/tcp   epic_mccarthy

$ tail -f /var/log/shinyproxy.out.log
2019-02-06 11:15:59.825  INFO 16925 --- [  XNIO-2 task-6] c.s.docker.client.DefaultDockerClient    : Starting container with Id: e2aa1d1bc4478b85ab7f7f53739ee99fb61910b8d25ec162970df74cea14d7be
2019-02-06 11:16:02.180  WARN 16925 --- [  XNIO-2 task-6] e.o.shinyproxy.ShinyProxyTestStrategy    : Container unresponsive, trying again (2/10000): http://localhost:20000

Unfortunately, this leads to the same result. The image is rebuilt when I open the app in the browser.

I just noticed something else, that leads me to the assumption, that the docker image is not the problem.

There is a File called global.R in the app with the following code:

requiredpackages <- c("shinyalert",
                  "hexView",  ## for functiopn
                  "wavelets", ## for transfer function
                  "parallel", ## for transfer function
                  "Rcpp" ## for transfer function

toinstall <- requiredpackages[!requiredpackages %in% rownames(installed.packages())]

if(length(toinstall) > 0){

lapply(requiredpackages, FUN = require, character.only = TRUE) 

I’m by no means an R developer (just got the task to make the app available online). But this looks like the packages get installed every time because of this code.

Then it’s just the missing R packages being installed rather than the docker image being rebuilt … just including the packages in your docker image should solve the issue…

1 Like

Exactly - I misread the output. It is working now.

Still needs about 20 seconds to get started. But I don’t think I can cut that down any more.

Thank you very much for your help.

Normally it won’t take that long time to launch an app… anyway it’s good to hear your problem being solved.

Yeah, I thought so. The examples are starting pretty quick. I might have to go back to the R developer and tackle that with him.

Thanks again!