相关疑难解决方法(0)

如何在docker compose中将主机目录挂载为卷

我有一个开发环境,我是dockerizing,我希望能够重新生成我的更改,而无需重建docker镜像.我正在使用docker compose,因为redis是我应用程序的依赖项之一,我喜欢能够链接redis容器

我有两个容器定义docker-compose.yml:

node:
    build: ./node
    links:
        - redis
    ports:
        - "8080"
    env_file:
        - node-app.env

redis:
    image: redis
    ports:
        - "6379"
Run Code Online (Sandbox Code Playgroud)

我已经在我的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 …
Run Code Online (Sandbox Code Playgroud)

docker docker-compose docker-volume

94
推荐指数
6
解决办法
12万
查看次数

标签 统计

docker ×1

docker-compose ×1

docker-volume ×1