rocker-org / rocker-versioned2

Run current & prior versions of R using docker. rocker/r-ver, rocker/rstudio, rocker/shiny, rocker/tidyverse, and so on.
https://rocker-project.org
GNU General Public License v2.0
390 stars 163 forks source link

rocker/shiny:4.4.0 exposes port 8787 instead of 3838? #811

Closed gsmolinski closed 1 month ago

gsmolinski commented 1 month ago

Container image name

rocker/shiny:4.4.0

Container image digest

No response

What operating system are you seeing the problem on?

Windows

System information

Docker version 25.0.3, build 4debf41

Bug description

Let's start by saying that I'm not very familiar with docker, just from time to time I run some simple dockerfiles written based on beginning tutorials.

Below is some standard dockerfile I used few times in previous months to run shiny server with my applications:

FROM rocker/shiny:4.4.0

RUN apt-get update -qq && apt-get -y --no-install-recommends install \
    libxml2-dev \
    libcairo2-dev \
    libsqlite3-dev \
    libssh2-1-dev \
    unixodbc-dev \
    libcurl4-openssl-dev \
    libssl-dev

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

WORKDIR /srv/shiny-server/

COPY ./mobile_phones_sampling/renv.lock ./renv.lock

COPY ./mobile_phones_sampling ./mobile_phones_sampling

ENV RENV_PATHS_LIBRARY renv/library

RUN R -e "renv::restore()"

RUN sudo chown -R shiny:shiny /srv/shiny-server

USER shiny

What I generally change is just changeing version of rocker/shiny and content of apt-get-update (as well as application name of course). However, I noticed yesterday that after building the image on Windows using Docker Desktop, I have a problem to access shiny server (when I open localhost, I got message that connection was reset on Firefox). Then I realized that port is set to 8787 while in images I have from previous months it is set to 3838. I decided to add EXPOSE 3838 to my script:

FROM rocker/shiny:4.4.0

RUN apt-get update -qq && apt-get -y --no-install-recommends install \
    libxml2-dev \
    libcairo2-dev \
    libsqlite3-dev \
    libssh2-1-dev \
    unixodbc-dev \
    libcurl4-openssl-dev \
    libssl-dev

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

WORKDIR /srv/shiny-server/

COPY ./mobile_phones_sampling/renv.lock ./renv.lock

COPY ./mobile_phones_sampling ./mobile_phones_sampling

ENV RENV_PATHS_LIBRARY renv/library

RUN R -e "renv::restore()"

EXPOSE 3838

RUN sudo chown -R shiny:shiny /srv/shiny-server

USER shiny

and now I was able to run shiny server on this port and no connection problem.

To summarize: previously it was possible to run script I have without EXPOSE 3838 and everything was OK. Now it is needed to add this part to be able to connect with shiny server.

How to reproduce this bug?

No response

eitsupi commented 1 month ago

Thanks for finding this!

But since the EXPOSE clause doesn't actually expose the port, I don't think you need to write a Dockerfile. Please check the documentation. https://docs.docker.com/reference/dockerfile/#expose