[英]Dockerizing shiny-app using a Dockerfile
I want to dockerize a basic shiny-app using a Dockerfile and subsequently running docker build .
我想使用Dockerfile来对基本的Shiny-app进行Docker化,然后运行docker
docker build .
from the working directory. 从工作目录。 I am looking at docker docs but cannot really tell the issue with my Dockerfile code.
我正在查看docker文档,但无法用我的Dockerfile代码真正说明问题。
The shiny-app 闪亮的应用程序
## libraries ##
library(data.table)
library(ggplot2)
library(shinydashboard)
## load data ##
google_data <- data.table(Date = c("01/01/2017",
"01/02/2017",
"01/03/2017"),
AdjClose = c(1200,
1250,
1150))
## ui.R ##
library(shinydashboard)
ui <- dashboardPage(
dashboardHeader(title = "Google Stock Price"),
dashboardSidebar(),
dashboardBody(plotOutput("google_plot"))
)
## server.R ##
server <- function(input, output) {
output$google_plot <- renderPlot({
ggplot(google_data, aes(x = Date, y = AdjClose, group = 1)) +
geom_line()
})
}
shinyApp(ui, server)
My Dockerfile 我的Dockerfile
FROM quantumobject/docker-shiny
LABEL maintainer = "The Greconomist"
COPY app.R /var/wwww/
WORKDIR /var/www/
RUN R -e "install.packages('gtable', repos='https://cran.rstudio.com/')"
RUN R -e "install.packages('data.table', repos='http://cran.rstudio.com/')"
RUN R -e "install.packages('shinydashboard', repos='http://cran.rstudio.com/')"
RUN R -e "install.packages('ggplot2', repos='http://cran.rstudio.com/')"
EXPOSE 3838
I am using / extending the quantumobject/docker-shiny image found in docker hub. 我正在使用/扩展在docker hub中找到的quantumobject / docker-shiny映像。 When running the
docker build .
在运行
docker build .
the build is successful, but unable to to do a docker run [IMAGE]
. 构建成功,但是无法执行
docker run [IMAGE]
。
The result from docker run [IMAGE]
is: docker run [IMAGE]
的结果是:
Starting pre-service scritps in /etc/my_init.d
*** Running: /etc/my_init.d/startup.sh
starting rc.local scritps
*** Running: /etc/rc.local
Booting runit daemon...
Process runsvdir running with PID 178
[2018-03-14 09:40:27.933] [INFO] shiny-server - Shiny Server v1.5.6.875 (Node.js v6.10.3)
[2018-03-14 09:40:27.937] [INFO] shiny-server - Using config file "/etc/shiny-server/shiny-server.conf"
[2018-03-14 09:40:27.982] [INFO] shiny-server - Starting listener on 0.0.0.0:3838
But accessing localhost:3838 give me nothing 但是访问localhost:3838没有任何帮助
The basic usage info for the base image at https://github.com/QuantumObject/docker-shiny applies also to the derived image: You have to tell docker that you want port 3838 from the container mapped to the host: https://github.com/QuantumObject/docker-shiny上基本映像的基本用法信息也适用于派生映像:您必须告诉docker您想要从映射到主机的容器获取端口3838:
docker run -p 3838:3838 [IMAGE]
In addition, you should copy app.R
to /srv/shiny-server
. 另外,您应该将
app.R
复制到/srv/shiny-server
。 BTW, I would move that step to the end of your Dockerfile
to make caching of intermediate images possible. 顺便说一句,我
Dockerfile
一步移至Dockerfile
的末尾,以实现中间映像的缓存。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.