{"record":{"id":"b58575ba7193932c","repo":"crowdsecurity/crowdsec","slug":"no-container-found-named-s-can-t-run-one-shot-a","errorCode":null,"errorMessage":"no container found named: %s, can't run one shot acquisition","messagePattern":"no container found named: (.+?), can't run one shot acquisition","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/acquisition/modules/docker/run.go","lineNumber":126,"sourceCode":"\t\t\t\t\tout <- evt\n\n\t\t\t\t\td.logger.Debugf(\"Sent line to parsing: %+v\", evt.Line.Raw)\n\t\t\t\t}\n\t\t\t}\n\n\t\t\terr = scanner.Err()\n\t\t\tif err != nil {\n\t\t\t\td.logger.Errorf(\"Got error from docker read: %s\", err)\n\t\t\t}\n\n\t\t\td.runningContainerState.Set(container.ID, containerConfig)\n\t\t}\n\t}\n\n\tt.Kill(nil)\n\n\tif !foundOne {\n\t\treturn fmt.Errorf(\"no container found named: %s, can't run one shot acquisition\", d.Config.ContainerName[0])\n\t}\n\n\treturn nil\n}\n\nfunc (d *Source) EvalContainer(ctx context.Context, container dockerContainer.Summary) *ContainerConfig {\n\t// fixed params\n\tnewConfig := func(name string, labels map[string]string) *ContainerConfig {\n\t\treturn NewContainerConfig(d.containerLogsOptions, container.ID, name, labels, d.getContainerTTY(ctx, container.ID))\n\t}\n\n\t// ID match\n\n\tif slices.Contains(d.Config.ContainerID, container.ID) {\n\t\treturn newConfig(container.Names[0], d.Config.Labels)\n\t}\n\n\t// name match","sourceCodeStart":108,"sourceCodeEnd":144,"githubUrl":"https://github.com/crowdsecurity/crowdsec/blob/909b5157986a2b2c2163300fdaef5ed01289f7d2/pkg/acquisition/modules/docker/run.go#L108-L144","documentation":"OneShotAcquisition (crowdsec docker datasource, `docker run --rm -i` style one-shot mode) iterates the configured containers via `docker ps`/list and sets foundOne only when a container matching Config.ContainerName[0] is found. If no running container matches the configured name at acquisition time, it returns this error instead of reading logs. It means the requested container does not exist or is not currently running.","triggerScenarios":"Running one-shot docker acquisition (`cscli`/`crowdsec -type docker` one-shot, e.g. in CI or tests) with Config.ContainerName[0] set to a name that does not match any running container — wrong name, container stopped/exited, or only an ID prefix given where exact name/ID matching is expected.","commonSituations":"Typo in container_name in acquis.yaml; container crashed before the acquisition ran; using a docker-socket-proxy that hides the container; testing with `docker run` on a host where the container was already removed; name given with leading slash or compose-prefixed name (e.g. project_service_1) that doesn't match.","solutions":["Verify the container is running: `docker ps | grep <name>`, and use the exact name or full ID from that output in container_name.","Start the target container before running one-shot acquisition.","If using docker-socket-proxy, allow the container list/inspect endpoints so the source can find the container.","Check EvalContainer matching (name, ID prefix, or regexp match in pkg/acquisition/modules/docker/run.go) and align your configured name with the matching rules."],"exampleFix":"// before (acquis.yaml)\nsource: docker\ncontainer_name:\n  - my-nginx\n// after — match the real running container name shown by `docker ps`\nsource: docker\ncontainer_name:\n  - /nginx$","handlingStrategy":"validation","validationCode":"// Go, before OneShotAcquisition\nfunc containerRunning(ctx context.Context, cli *client.Client, name string) (bool, error) {\n\tsums, err := cli.ContainerList(ctx, container.ListOptions{})\n\tif err != nil {\n\t\treturn false, err\n\t}\n\tfor _, s := range sums {\n\t\tfor _, n := range s.Names {\n\t\t\tif strings.TrimPrefix(n, \"/\") == name || s.ID == name {\n\t\t\t\treturn true, nil\n\t\t\t}\n\t\t}\n\t}\n\treturn false, nil\n}","typeGuard":"if !found {\n\treturn fmt.Errorf(\"container %q not running; check `docker ps` before one-shot acquisition\", name)\n}","tryCatchPattern":"err := src.OneShotAcquisition(ctx, out)\nif err != nil && strings.Contains(err.Error(), \"no container found named\") {\n\t// resolve correct container name/ID and retry\n}","preventionTips":["Assert the container is up with `docker ps` in CI before running one-shot docker acquisition.","Use the exact container name or full ID as reported by docker, not an alias.","When using docker-socket-proxy, confirm container list endpoints are permitted."],"tags":["docker","acquisition","container-not-found"],"backgroundTag":"entity-not-found","analyzedSha":"909b5157986a2b2c2163300fdaef5ed01289f7d2","analyzedAt":"2026-09-06T12:27:26.012Z","contentChangedAt":"2026-09-06T12:27:26.012Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}