【发布时间】:2020-06-24 15:46:54
【问题描述】:
我正在尝试创建一个 Dockerized Flexdashboard 应用程序。我可以在本地运行它,但不能在本地主机中运行。 但是,我可以在同一个 docker 映像中运行闪亮的应用程序。有趣的是,本地主机中的错误消息显示 Flexdashboard 应用程序的“未找到”,这与页面根本不存在时不同(“未找到页面”)。
如何 Dockerize 一个 Flexdashboard 应用程序?
MWE
dir.create("testshinydocker")
dir.create("testshinydocker/apps")
dir.create("testshinydocker/apps/kmeans")
dir.create("testshinydocker/apps/kmeansflex")
cat(readLines("https://raw.githubusercontent.com/rstudio/shiny-examples/master/050-kmeans-example/server.R"),
file = "testshinydocker/apps/kmeans/server.R", sep = "\n")
cat(readLines("https://raw.githubusercontent.com/rstudio/shiny-examples/master/050-kmeans-example/ui.R"),
file = "testshinydocker/apps/kmeans/ui.R", sep = "\n")
cat(
c('FROM rocker/shiny:latest\n',
"RUN echo 'install.packages(c(\"flexdashboard\"), \\",
"repos='$MRAN', \\",
"dependencies=TRUE)' > /tmp/packages.R \\",
" && Rscript /tmp/packages.R\n",
'EXPOSE 3838\n',
'COPY apps /srv/shiny-server/\n',
'CMD ["/usr/bin/shiny-server.sh"]\n'),
file = "testshinydocker/Dockerfile",
sep = "\n"
)
cat(readLines("https://raw.githubusercontent.com/rstudio/flexdashboard/master/examples/11_shiny-kmeans-clustering/dashboard.Rmd"),
file = "testshinydocker/apps/kmeansflex/kmeans2.Rmd", sep = "\n")
shiny::runApp('testshinydocker/apps/kmeans')
rmarkdown::run("testshinydocker/apps/kmeansflex/kmeans2.Rmd")
Docker 代码(在 Powershell 中运行)
cd {path to testshinydocker directory}
docker build -t myapp .
docker run --rm -d -p 3838:3838 myapp
本地主机 URL
- http://localhost:3838/kmeans(工作)
- http://localhost:3838/kmeansflex(“未找到”错误)
- http://localhost:3838/dinosaurs(“找不到页面”错误)
【问题讨论】:
-
嗯,我运行了你的确切代码,可以看到
http://localhost:3838/kmeansflex应用程序。 -
谢谢@TylerRinker - 我真的被这个难住了。我怀疑这是我个人机器上的设置问题,希望有人对此有经验。
标签: r docker shiny flexdashboard