Docker-Compose装载卷会覆盖主机文件 [英] Docker-Compose mount volume overwrites host files

查看:318
本文介绍了Docker-Compose装载卷会覆盖主机文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在从CMS装入目录,其中目录文件包含在Docker容器中.

I am mounting a directory from a CMS with content files inside a docker container.

安装绝对正确.CMS获得了一些基本文件,这些文件在构建过程中被复制到容器中的已安装文件夹中.然后,它将被挂载到主机上的目录中.现在,来自Container的文件也位于主机上.我可以更改它们,它们将保持同步.

The mounting works absolutely. The CMS got some basic files, which are copied into the mounted folder in the container during build. Then it will be mounted to a directory on the host. Now the files from the Container are also on the host. I can change them and they will be kept in sync.

如果我重新启动容器 docker-compose stop && docker-compose up -d 主机上的文件将被容器构建中的默认文件覆盖.

If i restart my container docker-compose stop && docker-compose up -d the files on the host will be overwritten by the default ones from the container build.

是否可以强制文件的本地状态覆盖容器中的文件?

Is there a possibility to force the local state of the file to overwrite the file in the container?

亲切的问候

推荐答案

也许尝试将其配置为只读

maybe try configuring it as read only

docker run -v volume-name:/path/in/container:ro my/image

这篇关于Docker-Compose装载卷会覆盖主机文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆