Merge pull request #1282 from runcom/etc-hosts-kube
container_create: only bind mount /etc/hosts if not provided by k8s
This commit is contained in:
commit
4b658672aa
1 changed files with 11 additions and 2 deletions
|
@ -1079,8 +1079,17 @@ func (s *Server) createSandboxContainer(ctx context.Context, containerID string,
|
|||
specgen.AddMount(mnt)
|
||||
}
|
||||
|
||||
// Bind mount /etc/hosts for host networking containers
|
||||
if hostNetwork(containerConfig) {
|
||||
isInCRIMounts := func(dst string, mounts []*pb.Mount) bool {
|
||||
for _, m := range mounts {
|
||||
if m.ContainerPath == dst {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
if !isInCRIMounts("/etc/hosts", containerConfig.GetMounts()) && hostNetwork(containerConfig) {
|
||||
// Only bind mount for host netns and when CRI does not give us any hosts file
|
||||
mnt = rspec.Mount{
|
||||
Type: "bind",
|
||||
Source: "/etc/hosts",
|
||||
|
|
Loading…
Reference in a new issue