gpt4 book ai didi

docker - 从主机映射卷更改时,容器文件未更新

转载 作者:行者123 更新时间:2023-12-02 18:15:51 25 4
gpt4 key购买 nike

我有以下docker-compose.yml:

version: '3'

services:
web:
build:
context: .
dockerfile: ./.docker/node.dockerfile
volumes:
- D:\Proj\Web:/app
ports:
- '3000:3000'
depends_on:
- 'db'
networks:
- holder-network
restart: on-failure
tty: true


db:
image: mysql:5.7
volumes:
- db_data:/var/lib/mysql
networks:
- holder-network
restart: always
environment:
MYSQL_ROOT_PASSWORD: P@ssw0rd
MYSQL_DATABASE: holder_db
MYSQL_USER: holder_usr
MYSQL_PASSWORD: P@ssw0rd


networks:
holder-network:
driver: bridge

volumes:
db_data:

node.dockerfile:
FROM node:7.10

MAINTAINER Juliano Nunes

RUN mkdir /var/www

RUN npm install nodemon -g

WORKDIR /var/www

ADD . /var/www

RUN npm install

CMD nodemon

我正在从主机更改 D:\Proj\Web下的文件,但是它不会更新容器中的文件。为什么?

最佳答案

我发现了错误。我的docker-compose.yml使用/app作为路径,而node.dockerfile使用/var/www

这是更新(工作)的版本:

version: '3'

services:
web:
build:
context: .
dockerfile: ./.docker/node.dockerfile
volumes:
- D:\Proj\Web:/var/www
ports:
- '3000:3000'
depends_on:
- 'db'
networks:
- holder-network
restart: on-failure
tty: true


db:
image: mysql:5.7
volumes:
- db_data:/var/lib/mysql
networks:
- holder-network
restart: always
environment:
MYSQL_ROOT_PASSWORD: P@ssw0rd
MYSQL_DATABASE: holder_db
MYSQL_USER: holder_usr
MYSQL_PASSWORD: P@ssw0rd


networks:
holder-network:
driver: bridge

volumes:
db_data:

关于docker - 从主机映射卷更改时,容器文件未更新,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44102318/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com