我是 docker 新手,正在尝试构建我的开发容器。我想在开发时为 concat 文件运行watchify ( https://www.npmjs.com/package/watchify )。
Docker 可以管理卷。我可以watchify在我的系统上运行,但我想把它放在 docker host 上。
我设法构建容器和图像。
"scripts": {
"watchjs": "node_modules/.bin/watchify ./public/js/dependencies.js -o ./public/js/all.js",
"start:dev": "npm run watchjs & node app.js"
}
当使用“npm run start:dev”运行容器时,它就会退出。
知道为什么会这样吗?我可以在容器上运行 watchjs 和节点应用程序吗?
这就是我构建图像/容器的方式:
# Build your image
docker build -t albertof/blog .
# Docker create container
docker create -P --name blog-container -v ~/Projects/Docker/example:/Blog albertof/blog
# Docker start running container
docker start blog-container
这里是我的 Dockerfile
FROM node:argon
MAINTAINER XXX ZZZ xxx@zzz.com
# Update libraries and dependencies
# RUN apt-get update -qq
# Install bower
RUN npm install -g bower
# Make folder that contains blog
RUN mkdir -p Blog
# Set up working directory (from now on we are located inside /Blog)
WORKDIR /Blog
# Expose server
EXPOSE 8000
#
# LEAVE FILES THAT CHANGE OFTEN AT THE END
#
# THIS WILL ALLOW DOCKER TO BUILD FASTER
#
# STEPS WILL BE EXECUTED ALL OVER SINCE THE MOMENT IT FIND DIFFS
#
# Add npm
ADD ./package.json .
# Install dependencies defined in packaje.json
RUN npm install
# Add bower.json
ADD ./bower.json .
# Install bower components
RUN bower install --config.interactive --allow-root
ENTRYPOINT ["npm"]
CMD ["start:dev"]