diff --git a/KubeArmor/core/dockerHandler.go b/KubeArmor/core/dockerHandler.go index 761ca1e855..ef1861b512 100644 --- a/KubeArmor/core/dockerHandler.go +++ b/KubeArmor/core/dockerHandler.go @@ -172,9 +172,9 @@ func (dh *DockerHandler) GetEventChannel() <-chan events.Message { // GetAlreadyDeployedDockerContainers Function func (dm *KubeArmorDaemon) GetAlreadyDeployedDockerContainers() { - // check if Docker exists + // check if Docker exists else instantiate if Docker == nil { - return + Docker = NewDockerHandler() } if containerList, err := Docker.DockerClient.ContainerList(context.Background(), types.ContainerListOptions{}); err == nil { @@ -376,11 +376,9 @@ func (dm *KubeArmorDaemon) MonitorDockerEvents() { dm.WgDaemon.Add(1) defer dm.WgDaemon.Done() - Docker = NewDockerHandler() - - // check if Docker exists + // check if Docker exists else instantiate if Docker == nil { - return + Docker = NewDockerHandler() } dm.Logger.Print("Started to monitor Docker events") diff --git a/KubeArmor/core/kubeArmor.go b/KubeArmor/core/kubeArmor.go index c999260e76..9811269838 100644 --- a/KubeArmor/core/kubeArmor.go +++ b/KubeArmor/core/kubeArmor.go @@ -461,15 +461,15 @@ func KubeArmor() { } // monitor containers - if strings.Contains(cfg.GlobalCfg.CRISocket, "docker") { + if strings.Contains(dm.Node.ContainerRuntimeVersion, "docker") { // update already deployed containers dm.GetAlreadyDeployedDockerContainers() // monitor docker events go dm.MonitorDockerEvents() - } else if strings.Contains(cfg.GlobalCfg.CRISocket, "containerd") { + } else if strings.Contains(dm.Node.ContainerRuntimeVersion, "containerd") { // monitor containerd events go dm.MonitorContainerdEvents() - } else if strings.Contains(cfg.GlobalCfg.CRISocket, "crio") { + } else if strings.Contains(dm.Node.ContainerRuntimeVersion, "crio") { // monitor crio events go dm.MonitorCrioEvents() } else {