ns2docker

package module
v0.0.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 8, 2021 License: Apache-2.0 Imports: 6 Imported by: 0

README

获取docker容器列表

通过namespace查询容器信息

    dockerContainer := ns2docker.Search("4026532229")
    log.Infof("使用namespace: %v 查询到容器: %v","4026532229",dockerContainer)

通过容器ID查询namespace

    if namespace,err := ns2docker.QueryNs("bf5d97f08b5a");err == nil {
        log.Infof("使用容器ID:%s 查询到namespace: %v","bf5d97f08b5a",namespace)
    }else{
        log.Error(err.Error())
    }

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddDockerNsCache added in v0.0.5

func AddDockerNsCache()

func LoadDockerNsCache

func LoadDockerNsCache()

func QueryNs

func QueryNs(containerID string) (namespace string, err error)

func SearchContainerName added in v0.0.4

func SearchContainerName(namespace string) string

func SearchOverlay2 added in v0.0.4

func SearchOverlay2(namespace string, typeName string) string

Types

type NsCache

type NsCache struct {
	Ns2Container map[string]types.ContainerJSON
	PoolMutex    *sync.RWMutex
}
var DockerNsCache *NsCache

func NewNsCache

func NewNsCache() (ns *NsCache)

func (*NsCache) Clear

func (nc *NsCache) Clear()

func (*NsCache) Del

func (nc *NsCache) Del(key string)

func (*NsCache) Get

func (nc *NsCache) Get(key string) (types.ContainerJSON, bool)

func (*NsCache) Put

func (nc *NsCache) Put(key string, value types.ContainerJSON)

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL