【发布时间】:2021-03-13 12:23:43
【问题描述】:
我在一个 pod 中运行多个容器。我有一个持久化卷并将相同的目录挂载到容器中。
我的要求是:
将 /opt/app/logs/app.log 挂载到容器 A,应用程序将数据写入 app.log
将 /opt/app/logs/app.log 挂载到容器 B 以从 app.log
读回数据- container-A
image: nginx
volumeMounts:
- mountPath: /opt/app/logs/ => container A is writing data here to **app.log** file
name: data
- container-B
image: busybox
volumeMounts:
- mountPath: /opt/app/logs/ => container B read data from **app.log**
name: data
我面临的问题是 - 当我将同一目录 /opt/app/logs/ 挂载到容器 B 时,我没有看到 app.log强> 文件。
有人可以帮我解决这个问题吗?这是可以实现的,但我不确定我在这里缺少什么。
【问题讨论】:
-
容器 B 的挂载可能发生在容器 A 的安装之后,所以它什么都没有覆盖内容。
标签: kubernetes