crowdsecurity/crowdsec · error

use_container_labels and container_name, container_id, conta

Error message

use_container_labels and container_name, container_id, container_id_regexp, container_name_regexp are mutually exclusive

What it means

Validation guard in docker UnmarshalConfig: use_container_labels is enabled while explicit container selectors (container_name, container_id, container_id_regexp, container_name_regexp) are also set. Label-based discovery and explicit selection are mutually exclusive strategies; allowing both would make the watched set ambiguous.

Source

Thrown at pkg/acquisition/modules/docker/config.go:73

		FollowStdout: true, // default
		FollowStdErr: true, // default
	}

	if err := yaml.UnmarshalWithOptions(yamlConfig, &d.Config, yaml.Strict()); err != nil {
		return fmt.Errorf("while parsing DockerAcquisition configuration: %s", yaml.FormatError(err, false, false))
	}

	if d.logger != nil {
		d.logger.Tracef("DockerAcquisition configuration: %+v", d.Config)
	}

	// Check if we have any container or service configuration
	if !d.Config.hasContainerConfig() && !d.Config.hasServiceConfig() {
		return errors.New("no containers or services configuration provided")
	}

	if d.Config.UseContainerLabels && (len(d.Config.ContainerName) > 0 || len(d.Config.ContainerID) > 0 || len(d.Config.ContainerIDRegexp) > 0 || len(d.Config.ContainerNameRegexp) > 0) {
		return errors.New("use_container_labels and container_name, container_id, container_id_regexp, container_name_regexp are mutually exclusive")
	}

	if d.Config.UseServiceLabels && (len(d.Config.ServiceName) > 0 || len(d.Config.ServiceID) > 0 || len(d.Config.ServiceIDRegexp) > 0 || len(d.Config.ServiceNameRegexp) > 0) {
		return errors.New("use_service_labels and service_name, service_id, service_id_regexp, service_name_regexp are mutually exclusive")
	}

	if d.Config.CheckInterval != "" && d.logger != nil {
		d.logger.Warn("check_interval is ignored: this datasource now uses events instead of polling (will be removed in a future version)")
	}

	if d.Config.Mode == "" {
		d.Config.Mode = configuration.TAIL_MODE
	}

	if d.Config.Mode != configuration.CAT_MODE && d.Config.Mode != configuration.TAIL_MODE {
		return fmt.Errorf("unsupported mode %s for docker datasource", d.Config.Mode)
	}

View on GitHub (pinned to 909b515798)

Solutions

  1. Either set use_container_labels: true and remove all container_* selectors, or disable it and list containers explicitly
  2. Pick discovery-by-label when containers are ephemeral; pick explicit selectors for stable setups
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at pkg/acquisition/modules/docker/config.go:73 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of crowdsecurity/crowdsec@909b515798 (2026-09-06). Data as JSON: /api/errors/d7d8b5249fa00ebb. Report an issue: GitHub.