1
我有一個dockerfile與以下命令。沒有什麼花哨。 (上下文:從this tutorial製造)如何自動更新碼頭卷更新?
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
將不會更新。從我所知道的documentation,應該只是工作。掛載存在(見下文),以及一切構建和正確運行。所以我很茫然。有誰知道我做錯了什麼?
既然這是最簡單的碼頭集裝箱,我希望有人遇到過,並解決了這個問題。
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": ""
}
],
詛咒......你說得很對。感謝:/ – amflare
隨時歡迎! – Robert