Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Run Shiny-server on different port than 3838

I am deploying Shiny-server in container. By default Shiny-server listens on port 3838, here is piece from shiny-server.conf

# Instruct Shiny Server to run applications as the user "shiny"
run_as shiny;

# Define a server that listens on port 3838
server {
  listen 3838;

I would like to change this port to 80. I obviously can launch container instance, login to it, and change it, but I would like to change it in Dockerfile.

FROM rocker/shiny:3.5.1

RUN apt-get update && apt-get install libcurl4-openssl-dev libv8-3.14-dev -y &&\
  mkdir -p /var/lib/shiny-server/bookmarks/shiny

# Download and install library
RUN R -e "install.packages(c('shinydashboard', 'shinyjs', 'V8'))"

# copy the app to the image COPY shinyapps /srv/shiny-server/
COPY "reports" "/srv/shiny-server/sample-apps/reports/"

# make all app files readable (solves issue when dev in Windows, but building in Ubuntu)
RUN chmod -R 755 /srv/shiny-server/

EXPOSE 80
CMD ["/usr/bin/shiny-server.sh"] 

Is there command line option for final line in Dockerfile?

like image 738
user1700890 Avatar asked Nov 19 '25 18:11

user1700890


1 Answers

Add

RUN sed -i -e 's/\blisten 3838\b/listen 80/g' /path/to/shiny-server.conf

So perhaps ending up with:

FROM rocker/shiny:3.5.1

RUN apt-get update && apt-get install libcurl4-openssl-dev libv8-3.14-dev -y &&\
  mkdir -p /var/lib/shiny-server/bookmarks/shiny

# Download and install library
RUN R -e "install.packages(c('shinydashboard', 'shinyjs', 'V8'))"

# copy the app to the image COPY shinyapps /srv/shiny-server/
COPY "reports" "/srv/shiny-server/sample-apps/reports/"

# make all app files readable (solves issue when dev in Windows, but building in Ubuntu)
RUN chmod -R 755 /srv/shiny-server/

RUN sed -i -e 's/\blisten 3838\b/listen 80/g' /path/to/shiny-server.conf

EXPOSE 80
CMD ["/usr/bin/shiny-server.sh"]

(I know multiple layers can be inefficient if not compacted, over to you if you want to combine the sed line with the previous RUN command. You might want to combine more of those RUN lines, if that's a concern.)

like image 121
r2evans Avatar answered Nov 21 '25 08:11

r2evans