Ignore systemd 'containers' in the docker driver
This commit is contained in:
parent
e675b00a40
commit
7788c8bd27
@ -42,6 +42,10 @@ var DockerNamespace = "docker"
|
|||||||
var dockerRootDir = flag.String("docker_root", "/var/lib/docker", "Absolute path to the Docker state root directory (default: /var/lib/docker)")
|
var dockerRootDir = flag.String("docker_root", "/var/lib/docker", "Absolute path to the Docker state root directory (default: /var/lib/docker)")
|
||||||
var dockerRunDir = flag.String("docker_run", "/var/run/docker", "Absolute path to the Docker run directory (default: /var/run/docker)")
|
var dockerRunDir = flag.String("docker_run", "/var/run/docker", "Absolute path to the Docker run directory (default: /var/run/docker)")
|
||||||
|
|
||||||
|
// Regexp that identifies docker cgroups, containers started with
|
||||||
|
// --cgroup-parent have another prefix than 'docker'
|
||||||
|
var dockerCgroupRegexp = regexp.MustCompile(`[A-z]+-([a-z0-9]+)\.scope`)
|
||||||
|
|
||||||
// TODO(vmarmol): Export run dir too for newer Dockers.
|
// TODO(vmarmol): Export run dir too for newer Dockers.
|
||||||
// Directory holding Docker container state information.
|
// Directory holding Docker container state information.
|
||||||
func DockerStateDir() string {
|
func DockerStateDir() string {
|
||||||
@ -119,8 +123,9 @@ func ContainerNameToDockerId(name string) string {
|
|||||||
|
|
||||||
// Turn systemd cgroup name into Docker ID.
|
// Turn systemd cgroup name into Docker ID.
|
||||||
if UseSystemd() {
|
if UseSystemd() {
|
||||||
id = strings.TrimPrefix(id, "docker-")
|
if matches := dockerCgroupRegexp.FindStringSubmatch(id); matches != nil {
|
||||||
id = strings.TrimSuffix(id, ".scope")
|
id = matches[1]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return id
|
return id
|
||||||
@ -140,6 +145,12 @@ func FullContainerName(dockerId string) string {
|
|||||||
func (self *dockerFactory) CanHandleAndAccept(name string) (bool, bool, error) {
|
func (self *dockerFactory) CanHandleAndAccept(name string) (bool, bool, error) {
|
||||||
// docker factory accepts all containers it can handle.
|
// docker factory accepts all containers it can handle.
|
||||||
canAccept := true
|
canAccept := true
|
||||||
|
|
||||||
|
// When using Systemd all docker containers have a .scope suffix
|
||||||
|
if UseSystemd() && !strings.HasSuffix(path.Base(name), ".scope") {
|
||||||
|
return false, canAccept, nil
|
||||||
|
}
|
||||||
|
|
||||||
// Check if the container is known to docker and it is active.
|
// Check if the container is known to docker and it is active.
|
||||||
id := ContainerNameToDockerId(name)
|
id := ContainerNameToDockerId(name)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user