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 when it should say that it is listening on 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.


FROM openanalytics/r-base
MAINTAINER Daniel Beachnau ""
# 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 \
# basic shiny functionality
RUN R -e "install.packages(c('shiny', 'shinydashboard', 'shinythemes', 'devtools', 'tinytex','shinyWidgets','shinycssloaders','shinyBS','shinyjs','flexdashboard'), repos='')"
# install dependencies of the app
RUN R -e "devtools::install_github('hadley/ggplot2')"
RUN R -e "devtools::install_version('rmarkdown', version = '1.8', repos = '')"
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='')"
RUN R -e "install.packages(c('RMySQL'), repos='')"
# copy the app to the image
RUN mkdir /root/app
COPY app /root/app
COPY /usr/lib/R/etc/

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

Any help would be greatly appreciated.


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 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 in the Dockerfile, but could be that it’s contents are different across apps?