我无法将HostPath /var/lib/docker/containers
用作卷,并出现以下错误:
Error response from daemon: linux mounts: Path /var/lib/docker/containers is
mounted on /var/lib/docker/containers but it is not a shared or slave mount.
这是我的YAML规范(请注意:这只是重现我在收集日志时遇到的问题的示例):
apiVersion: apps/v1
kind: Deployment
metadata:
name: test
namespace: logging
labels:
app: test
spec:
selector:
matchLabels:
app : test
template:
metadata:
labels:
app: test
spec:
containers:
- name: nginx
image: nginx:stable-alpine
securityContext:
privileged: true
ports:
- containerPort : 8003
volumeMounts:
- name: docker
mountPath: /var/lib/docker/containers
readOnly: true
volumes:
- name: docker
hostPath:
path: /var/lib/docker/containers
还有我的kubernetes版本。
Client Version: version.Info{Major:"1", Minor:"10", GitVersion:"v1.10.1",
GitCommit:"d4ab47518836c750f9949b9e0d387f20fb92260b", GitTreeState:"clean",
BuildDate:"2018-04-12T14:26:04Z", GoVersion:"go1.9.3", Compiler:"gc",
Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"10", GitVersion:"v1.10.0",
GitCommit:"fc32d2f3698e36b93322a3465f63a14e9f0eaead", GitTreeState:"clean",
BuildDate:"2018-03-26T16:44:10Z", GoVersion:"go1.9.3", Compiler:"gc",
Platform:"linux/amd64"}
非常感谢您的帮助!
答案 0 :(得分:2)
非常感谢您的帮助!
您最有可能受到版本特定问题的困扰:
/var/lib/docker/containers is intentionally mounted by Docker with private mount
propagation and thus conflicts with Kubernetes trying to mount this directory
as rslave when running the container
您应该尝试使用1.10.3+来解决。有关kubernetes的信息,请参见the official changelog,并检查与“默认安装传播”有关的条目。另外,请检查相关信息(请参见错误)fluentd issue,以进行更深入的分析。
现在,这样说...
David经验丰富且带有警告和谨慎字眼的评论仍然存在,我第二个观点是:这真是使人惊讶的事-Nginx Pod深入研究了docker引擎内部(希望只是为了减少可重现的示例或日志收集案例,你知道,有什么...)...只要确保你确切知道你在做什么,为什么。