我想使用Dockerfile将一个基本的闪亮应用程序停靠,然后从工作目录运行docker build .
。我正在查看docker docs,但无法用我的Dockerfile代码告诉它。
闪亮的应用
## 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)
我的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
我正在使用/扩展在docker hub中找到的quantumobject / docker-shiny image。运行docker build .
时,构建成功,但无法执行docker run [IMAGE]
。
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
答案 0 :(得分:0)
https://github.com/QuantumObject/docker-shiny基本映像的基本用法信息也适用于派生映像:您必须告诉docker您希望容器中的端口3838映射到主机:
docker run -p 3838:3838 [IMAGE]
此外,您应将app.R
复制到/srv/shiny-server
。顺便说一下,我会将这一步移到Dockerfile
的末尾,以便可以缓存中间图像。