Docker Compose 将新文件加载到容器

Docker Compose Load New Files to Container

我有一个 Docker 启动 Angular、React 和 Python 应用程序的 Compose 文件。 我希望在本地计算机上修改文件后重新加载容器。

例如,如果我在我的计算机上更改文件“package.json”,我希望新文件将重新加载到相关容器上,并希望 npm 进程重新启动并继续使用新文件.

这可能吗?

这是我的 docker 撰写文件:

version: '3'
services:
    server:
        build: ./insurance_site
        ports:
            - 8000:8000
        restart: on-failure            
    angular:
        build: ./fuse
        command: gulp serve watch      
        ports:
            - 3000:3000
        restart: on-failure
    react:
        build: ./react
        command: npm start         
        ports:
            - 3001:3001           
        restart: on-failure
    admin:
        build: ./admin-tools
        command: npm start     
        ports:
            - 3002:3002
        restart: on-failure         

提前致谢!

If I change the file "package.json" on my computer, I wish that the new file will be reloaded on the relevant container

使用volumes。他们就是这么做的。

I would like the container to reload once a file is being modified

这并不像在 docker-compose.yml 文件中添加两行那么简单。检查 this,它可能会有所帮助。