最佳答案
我有一个开发环境,我正在dockerizing,我希望能够重载我的变化,而不必重建docker图像。我使用docker撰写,因为redis是我的应用程序的依赖项之一,我喜欢能够链接一个redis容器
在docker-compose.yml
中定义了两个容器:
node:
build: ./node
links:
- redis
ports:
- "8080"
env_file:
- node-app.env
redis:
image: redis
ports:
- "6379"
我已经在我的node
应用程序的dockerfile中添加了一个卷,但是我如何在卷中挂载主机的目录,以便我对代码的所有实时编辑都反映在容器中?
这是我当前的Dockerfile:
# Set the base image to Ubuntu
FROM node:boron
# File Author / Maintainer
MAINTAINER Amin Shah Gilani <amin@gilani.me>
# Install nodemon
RUN npm install -g nodemon
# Add a /app volume
VOLUME ["/app"]
# TODO: link the current . to /app
# Define working directory
WORKDIR /app
# Run npm install
RUN npm install
# Expose port
EXPOSE 8080
# Run app using nodemon
CMD ["nodemon", "/app/app.js"]
我的项目是这样的:
/
- docker-compose.yml
- node-app.env
- node/
- app.js
- Dockerfile.js