r - 在不同于 3838 的端口上运行 Shiny-server
问题描述
我正在容器中部署 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
所以也许最终得到:
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
行。)
推荐阅读
- jenkins - 使用 jenkins-pipeline 将工件复制到远程机器
- vba - 查询使用的 VBA 函数未计算预期日期
- javascript - 双管道 - 未包含选项时未定义?
- python - 连接字符串和变量,给出类型错误,“标签”的操作数不受支持
- r - R中for循环中具有渲染功能的多个参数
- nginx - 在 nGinx Staticfile buildpack 中添加 X-Frame-Options
- java - 测试 java jersey 应用程序
- javascript - ReportViewer 15.0.0 渲染:Sys.ArgumentNullException:值不能为空。参数名称:元素
- ruby-on-rails - Rails 不会为 vue 加载 /javascript/packs
- c++ - Allowing a custom macro in #ifdef check