docker的VOLUME没有挂载主机文件

时间:2015-06-03 19:26:37

标签: node.js docker dockerfile

我有这个泊坞文件:

       date    value nearest_val_nextyear nearest_val_prevyear
1  2009-02-14 6.511781                    0                    0
2  2009-12-23 5.389843                    0                    0
3  2011-08-01 4.378759                    0                    0
4  2014-04-07 2.785300                    0                    0
5  2008-08-12 6.124931                    0                    0
6  2014-03-10 4.955066                    0                    0
7  2014-07-23 4.983810                    0                    0
8  2012-04-14 5.943836                    0                    0
9  2012-01-13 5.821221                    0                    0
10 2007-06-30 5.593901                    0                    0
11 2008-08-24 5.918977                    0                    0
12 2008-05-30 5.782136                    0                    0
13 2012-06-30 5.074565                    0                    0
14 2010-01-27 3.010648                    0                    0
15 2013-02-27 5.619826                    0                    0
16 2010-12-25 4.943871                    0                    0
17 2012-09-27 4.844204                    0                    0
18 2014-12-08 3.529248                    0                    0
19 2010-01-15 4.521850                    0                    0
20 2013-03-21 5.417942                    0                    0



# set start and end dates to sample between
day.start <- "2007/01/01"
day.end <- "2014/12/31"

set.seed(1)
# define a random date/time selection function
rand.day.time <- function(day.start,day.end,size) {
  dayseq <- seq.Date(as.Date(day.start),as.Date(day.end),by="day")
  dayselect <- sample(dayseq,size,replace=TRUE)
  as.POSIXlt(paste(dayselect) )
}

dateval=rand.day.time(day.start,day.end,size=20)
value=rnorm(n=20,mean=5,sd=1)
df=data.frame(date=dateval,value=value)
df$nearest_val_nextyear=0
df$nearest_val_prevyear=0
df

但是,当我运行容器时,我收到app.js不存在的错误,特别是FROM node:0.10.38 VOLUME /opt/build WORKDIR /opt/build EXPOSE 8080 CMD node app.js 不存在。我也试过/opt/build/app.jsADD来做这个,都说它找不到任何东西,我想使用VOLUME,所以它写入主机的日志也在/ opt中/建立。所有想要的文件实际上也在主机上。顺便说一下,我正在使用coreos作为主机操作系统。

1 个答案:

答案 0 :(得分:1)

http://docs.docker.com/userguide/dockervolumes/#volume -

中所述

VOLUME Dockerfile命令等同于-v /opt/build(“添加数据卷”),不等同于-v /opt/build:/opt/build(“将主机目录挂载为数据卷”);后者就是你想要的。