title: Shiny app not showing up after building Docker image and specifying port
body: <p>I'm currently trying to build a large Docker image and run a shiny application off of it so I can eventually deploy it to a Unix server. The image builds successfully; however, when I go to run the image, the app runs and totally ignores the specified port.</p>
  
  <p>What's even more strange is I first built a small test app, and the instructions from this SO post (<a href="https://stackoverflow.com/questions/52878149/shiny-app-docker-container-not-loading-in-browser">Shiny app docker container not loading in browser</a>) worked. I copied the same style I used in the test app into the other Shiny application and now it is not working.</p>
  
  <p>The structure of my Docker image follows a similar structure to what ShinyProxy used on their Github page: <a href="https://github.com/openanalytics/shinyproxy-template" rel="nofollow noreferrer">https://github.com/openanalytics/shinyproxy-template</a>:</p>
  
  <pre><code>|-- Dockerfile
  |-- Rprofile.site
  |-- app_stuff
      |-- app.R
      |-- accessory files called from app.R...
  </code></pre>
  
  <p>My <strong>Dockerfile</strong> is below:</p>
  
  <pre><code># Install R version 3.5.1
  FROM r-base:3.5.1
  
  # system libraries of general use - I don't know if these are right ????
  RUN apt-get update &amp;&amp; apt-get install -y \
      default-jdk \
      libbz2-dev \
      zlib1g-dev \
      gfortran \
      liblzma-dev \
      libpcre3-dev \
      libreadline-dev \
      xorg-dev \
      sudo \  
      pandoc \
      pandoc-citeproc \
      libcurl4-gnutls-dev \
      libcairo2-dev \
      libxt-dev \
      libssl-dev \
      libssh2-1-dev \
      libxml2-dev
  
  RUN R -e "install.packages('remotes');"
  RUN R -e "library(remotes); \
  remotes::install_version('shiny', version='1.1.0', repos='https://cran.r-project.org/'); \
  remotes::install_version('tidyverse', version='1.2.1', repos='https://cran.r-project.org/'); \
  remotes::install_version('ggiraph', version='0.6.0', repos='https://cran.r-project.org/'); \
  remotes::install_version('plotly', version='4.8.0', repos='https://cran.r-project.org/'); \
  remotes::install_version('CausalImpact', version='1.2.3', repos='https://cran.r-project.org/'); \
  remotes::install_version('reshape2', version='1.4.3', repos='https://cran.r-project.org/'); \
  remotes::install_version('bsts', version='0.8.0', repos='https://cran.r-project.org/'); \
  remotes::install_version('xts', version='0.10-2', repos='https://cran.r-project.org/'); \
  remotes::install_version('BoomSpikeSlab', version='1.0.0', repos='https://cran.r-project.org/'); \
  remotes::install_version('Boom', version='0.8', repos='https://cran.r-project.org/'); \
  remotes::install_version('MASS', version='7.3-50', repos='https://cran.r-project.org/'); \
  remotes::install_version('dygraphs', version='1.1.1.4', repos='https://cran.r-project.org/'); \
  remotes::install_version('prophet', version='0.4', repos='https://cran.r-project.org/'); \
  remotes::install_version('rlang', version='0.3.3', repos='https://cran.r-project.org/'); \
  remotes::install_version('Rcpp', version='1.0.1', repos='https://cran.r-project.org/'); \
  remotes::install_version('zoo', version='1.8-1', repos='https://cran.r-project.org/'); \
  remotes::install_version('RJDBC', version='0.2-7.1', repos='https://cran.r-project.org/'); \
  remotes::install_version('rJava', version='0.9-10', repos='https://cran.r-project.org/'); \
  remotes::install_version('shinyjs', version='1.0', repos='https://cran.r-project.org/'); \
  remotes::install_version('DT', version='0.5', repos='https://cran.r-project.org/'); \
  remotes::install_version('shinyBS', version='0.61', repos='https://cran.r-project.org/');"
  
  # copy the app to the image
  RUN mkdir /root/app_stuff
  COPY app_stuff /root/app_stuff
  
  COPY Rprofile.site /usr/lib/R/etc/
  
  EXPOSE 3838
  
  CMD ["R", "-e", "shiny::runApp('/root/app_stuff')"]
  </code></pre>
  
  <p>My <strong>Rprofile.site</strong> is:</p>
  
  <pre><code>local({
     options(shiny.port = 3838, shiny.host = "0.0.0.0")
  })
  </code></pre>
  
  <p>After building the file using the command  </p>
  
  <pre><code>docker build -t price_opt .
  </code></pre>
  
  <p>and then running the image </p>
  
  <pre><code>docker run -it -p 3838:3838 price_opt
  </code></pre>
  
  <p>I expected to see the shiny app print out: <code>Listening on http://0.0.0.0:3838</code>, but instead it prints out:</p>
  
  <pre><code>Listening on http://127.0.0.1:6688
  </code></pre>
  
  <p>Which I'm unable to find on my local machine. </p>
  
  <p>Again, the weirdest thing is this type of setup worked for a smaller shiny app. When I ran that <code>docker run</code> command from above on the smaller app, the app was available under localhost:3838.</p>
  
  <p>Any thoughts on why this is happening? My last thing is it looks like this user on the Shiny Proxy site had a similar issue (<a href="https://support.openanalytics.eu/t/shiny-app-listening-on-wrong-host/957" rel="nofollow noreferrer">https://support.openanalytics.eu/t/shiny-app-listening-on-wrong-host/957</a>). His issue is a typo of sorts, but it does seem to be acting the same way here where the Shiny app is totally ignoring the supplied port number in both Rprofile.site and the <code>docker run</code> command.</p>
  
  <h2>EDIT - Solution</h2>
  
  <p>Thanks to user @Wil, by changing the last line of the Dockerfile to <code>CMD ["R", "-e", "shiny::runApp('/root/app_stuff', host='0.0.0.0', port=3838)"]</code>, the app was able to start up normally on localhost:3838.</p>