如何自动更新docker卷?

时间:2017-06-06 20:15:32

标签: docker

我有一个带有以下命令的dockerfile。没有什么花哨。 (对于上下文:来自Insertion sort vs Bubble Sort Algorithms

FROM node:boron

# Create app directory
RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app

# Install app dependencies
COPY package.json /usr/src/app/
RUN npm install

# Bundle app source
ADD . /usr/src/app

EXPOSE 8080
CMD [ "npm", "start" ]

当我运行构建时,一切正常。

local:~/projects/tap/ws$ docker build -t test-img .
Sending build context to Docker daemon 13.82 kB
Step 1/8 : FROM node:boron
 ---> 3f3928767182
Step 2/8 : RUN mkdir -p /usr/src/app
 ---> Using cache
 ---> 8ba120374422
Step 3/8 : WORKDIR /usr/src/app
 ---> Using cache
 ---> c6f6cccd7833
Step 4/8 : COPY package.json /usr/src/app/
 ---> Using cache
 ---> 2c7f185c3e3f
Step 5/8 : RUN npm install
 ---> Using cache
 ---> 0197f3d8777b
Step 6/8 : ADD . /usr/src/app
 ---> 6a2df3e80f66
Removing intermediate container 93a56a2721e8
Step 7/8 : EXPOSE 8080
 ---> Running in ff21ca7efd15
 ---> 53cda9fd451f
Removing intermediate container ff21ca7efd15
Step 8/8 : CMD npm start
 ---> Running in 293d99bb9ca3
 ---> b8e026d96ba7
Removing intermediate container 293d99bb9ca3
Successfully built b8e026d96ba7

然后启动就好了。

local:~/projects/tap/ws$ docker run -p 49160:8080 -d -v /Users/amflare/projects/tap/ws/test:/user/src/app/test --name test test-img
22ce30a882be992cd245ef3bcb15a945b40c4507d2f56a366b410c12bbe9d801

但是当我在主机目录中进行更改时,挂载的卷/usr/src/app/test将不会更新。从this tutorial我可以看出,它应该工作。安装存在(见下文),所有内容都已构建并正确运行。所以我不知所措。有谁知道我做错了什么?

由于这是最简单的docker容器,我希望有人遇到过,并且之前解决了这个问题。

local:~/projects/tap/ws$ docker inspect test

...

Mounts": [
  {
    "Type": "bind",
    "Source": "/Users/amflare/projects/tap/ws/test",
    "Destination": "/user/src/app/test",
    "Mode": "",
    "RW": true,
    "Propagation": ""
  }
],

1 个答案:

答案 0 :(得分:2)

你在这里做了一个错字You cannot use Sum, Avg, StdDev, and Variance aggregations on date/time fields in sqlite3 since date/time is saved as text.。它应该是/user/src/app/test,而不是/usr。请修复您的/user

我可以看到它只是在Stack Overflow中不是拼写错误,因为你展示了这个:

docker run -v....