【问题标题】:Run Shiny-server on different port than 3838在不同于 3838 的端口上运行 Shiny-server
【发布时间】:2021-05-29 05:03:58
【问题描述】:

我正在容器中部署 Shiny-server。默认情况下,Shiny-server 侦听端口 3838,这是来自 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;

我想把这个端口改成80。我显然可以启动容器实例,登录它,然后改变它,但是我想在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"] 

Dockerfile 中最后一行是否有命令行选项?

【问题讨论】:

  • RUN sed -i -e 's/\blisten 3838\b/listen 80/g' /path/to/shiny-server.conf?
  • 另外,我喜欢将我的端口保持在 3838,当我运行它时,端口会在外部映射,如 docker --ports "80:3838" ...(或任何 cli 参数)。
  • @r2evans,谢谢,我打算在 Azure 上部署它。 Azure docker 实现不端口映射 afaik。
  • @r2evans,您的第一个评论有效,您可以作为解决方案发布,我会接受。我尝试创建 shiny-server.conf 文件的副本并对其进行编辑然后复制,但它以某种方式被覆盖

标签: r docker dockerfile shiny-server


【解决方案1】:

添加

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

所以可能以:

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"]

(我知道如果不压缩,多层可能会效率低下,如果您想将 sed 行与前面的 RUN 命令结合起来,请交给您。如果您想结合更多的 RUN 行,如果这是一个问题。)

【讨论】:

    猜你喜欢
    • 2014-09-23
    • 2014-04-14
    • 1970-01-01
    • 2019-03-27
    • 2023-04-07
    • 2018-01-14
    • 2020-06-07
    • 2016-03-01
    • 1970-01-01
    相关资源
    最近更新 更多