func (m *Monitor) Start() error {
	// Subscribe to docker events
	go m.listenForDockerEvents()
	// List already running containers
	containers, err := m.Client.ContainerList(context.Background(), types.ContainerListOptions{})
	if err != nil {
		return err
	}
	// Resolve container namespaces and add update data tree
	dockerLogger.Debugf("%v monitor is running", m.GetName())
	// Create container events for already running containers
	for _, c := range containers {
		cdata, err := m.createContainerEventFromContainerID(c.ID)
		if err != nil {
			continue
		}
		cdata.Timestamp = time.Now()
		cdata.EventType = model.ContainerRunningEventType
		if err := m.filterAndDispatchEvent(cdata); err != nil {
			dockerLogger.Errorf("Docker dispatch error: %v", err)
		}
	}
	return nil
}
// Start - Start event monitor
Start event monitor
// Start - Start event monitor
func (m *Monitor) Start() error {
	go m.listenForDockerEvents()
	containers, err := m.Client.ContainerList(context.Background(), types.ContainerListOptions{})
	if err != nil {
		return err
	}
	dockerLogger.Debugf("%v monitor is running", m.GetName())
	for _, c := range containers {
		cdata, err := m.createContainerEventFromContainerID(c.ID)
		if err != nil {
			continue
		}
		cdata.Timestamp = time.Now()
		cdata.EventType = model.ContainerRunningEventType
		if err := m.filterAndDispatchEvent(cdata); err != nil {
			dockerLogger.Errorf("Docker dispatch error: %v", err)
		}
	}
	return nil
}
func ( m * Monitor ) Start ( ) error { go m . listenForDockerEvents ( ) containers , err := m . Client . ContainerList ( context . Background ( ) , types . ContainerListOptions { } ) if err != nil { return err } dockerLogger . Debugf ( " " , m . GetName ( ) ) for _ , c := range containers { cdata , err := m . createContainerEventFromContainerID ( c . ID ) if err != nil { continue } cdata . Timestamp = time . Now ( ) cdata . EventType = model . ContainerRunningEventType if err := m . filterAndDispatchEvent ( cdata ) ; err != nil { dockerLogger . Errorf ( " " , err ) } } return nil }
Start event monitor
Start event monitor
// Subscribe to docker events // List already running containers // Resolve container namespaces and add update data tree // Create container events for already running containers