Shiny app listening on wrong host

When running my container it listens on the wrong host. I have other shiny apps that are working but when I try to run this one it reports that it is listening on http://127.0.0.1:6479 when it should say that it is listening on http://0.0.0.0:3838. I am building my image from the Dockerfile below and then running a container with docker run -p 3839:3838 --rm db/my_app R -e "shiny::runApp('/root/app/')".

Presumably, this explains the issue I am having where my container is reporting back unresponsive.

Dockerfile:

FROM openanalytics/r-base
 
MAINTAINER Daniel Beachnau "my_real_email@email.com"
 
# system libraries of general use
RUN apt-get update && apt-get install -y \
    sudo \
    gdebi-core \
    pandoc \
    pandoc-citeproc \
    libcurl4-gnutls-dev \
    libcairo2-dev \
    libxt-dev \
    libssl-dev \
    gsl-bin \
    libgsl0-dev \
    libxml2-dev \
    texlive-latex-base \
    texlive-fonts-recommended \
    texlive-fonts-extra \
    texlive-latex-extra \
    libmariadb-client-lgpl-dev
 
# basic shiny functionality
RUN R -e "install.packages(c('shiny', 'shinydashboard', 'shinythemes', 'devtools', 'tinytex','shinyWidgets','shinycssloaders','shinyBS','shinyjs','flexdashboard'), repos='https://cran.rstudio.com/')"
 
# install dependencies of the app
RUN R -e "devtools::install_github('hadley/ggplot2')"
RUN R -e "devtools::install_version('rmarkdown', version = '1.8', repos = 'http://cran.us.r-project.org')"
RUN R -e "install.packages(c('ggthemes','ggrepel','plyr','dplyr','plotly','scales','RColorBrewer','plotly','tidyr','RMySQL', 'numbers', 'lubridate', 'stringr', 'rlang', 'reshape2','jsonlite', 'knitr', 'kableExtra', 'gridExtra', 'xts', 'dygraphs'), repos='https://cran.rstudio.com/')"
RUN R -e "install.packages(c('RMySQL'), repos='https://cran.rstudio.com/')"
 
# copy the app to the image
RUN mkdir /root/app
COPY app /root/app
 
COPY Rprofile.site /usr/lib/R/etc/
 
EXPOSE 3838

CMD ["R", "-e", "shiny::runApp('/root/app', host='0.0.0.0', port=3838)"]

Any help would be greatly appreciated.

Hi,

By using the above you overwrite the CMD defined in the Dockerfile, so the host and port arguments are lost. You need to either add them to your run command, or just run the image with

docker run -p 3839:3838 --rm db/my_app

to use the default (defined in the Dockerfile’s CMD)

seeing this now, of course I should have seen that solution.

That does still leave me bothered why in one image, running the command without host and port specified works as intended (listening on 0.0.0.0:3838) and the other does not. As far as I can tell, the differences between the images should not impact the networking (although, clearly I am wrong here). At any rate, the issue I was having is solved so at this point, this is just me venting some frustrations. Thank you for your input.

The port and host can also be defined in the global options, e.g. in an Rprofile file. In fact I see that you do include Rprofile.site in the Dockerfile, but could be that it’s contents are different across apps?