{"record":{"id":"9e8bb0bdd20c7f02","repo":"nektos/act","slug":"cannot-parse-container-options-s-w","errorCode":null,"errorMessage":"Cannot parse container options: '%s': '%w'","messagePattern":"Cannot parse container options: '(.+?)': '%w'","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/container/docker_run.go","lineNumber":373,"sourceCode":"\tlogger := common.Logger(ctx)\n\tinput := cr.input\n\n\tif input.Options == \"\" {\n\t\treturn config, hostConfig, nil\n\t}\n\n\t// parse configuration from CLI container.options\n\tflags := pflag.NewFlagSet(\"container_flags\", pflag.ContinueOnError)\n\tcopts := addFlags(flags)\n\n\toptionsArgs, err := shellquote.Split(input.Options)\n\tif err != nil {\n\t\treturn nil, nil, fmt.Errorf(\"Cannot split container options: '%s': '%w'\", input.Options, err)\n\t}\n\n\terr = flags.Parse(optionsArgs)\n\tif err != nil {\n\t\treturn nil, nil, fmt.Errorf(\"Cannot parse container options: '%s': '%w'\", input.Options, err)\n\t}\n\n\tif len(copts.netMode.Value()) == 0 {\n\t\tif err = copts.netMode.Set(cr.input.NetworkMode); err != nil {\n\t\t\treturn nil, nil, fmt.Errorf(\"Cannot parse networkmode=%s. This is an internal error and should not happen: '%w'\", cr.input.NetworkMode, err)\n\t\t}\n\t}\n\n\tcontainerConfig, err := parse(flags, copts, runtime.GOOS)\n\tif err != nil {\n\t\treturn nil, nil, fmt.Errorf(\"Cannot process container options: '%s': '%w'\", input.Options, err)\n\t}\n\n\tlogger.Debugf(\"Custom container.Config from options ==> %+v\", containerConfig.Config)\n\n\terr = mergo.Merge(config, containerConfig.Config, mergo.WithOverride)\n\tif err != nil {\n\t\treturn nil, nil, fmt.Errorf(\"Cannot merge container.Config options: '%s': '%w'\", input.Options, err)","sourceCodeStart":355,"sourceCodeEnd":391,"githubUrl":"https://github.com/nektos/act/blob/4f411281417e88660bea1c1a1749aa71ae0bd60f/pkg/container/docker_run.go#L355-L391","documentation":"After shell-splitting succeeds, mergeContainerConfigs parses the option tokens with a pflag FlagSet (the docker-run-compatible flags registered by addFlags). Unknown flags, missing flag arguments, or malformed values make flags.Parse fail and produce 'Cannot parse container options' including the original string.","triggerScenarios":"Passing a flag act's embedded docker-run parser does not know (e.g. --detach, --gpus on a build without it), a flag missing its value (--memory with nothing after it at end of string), or values of the wrong type for the flag.","commonSituations":"Copying a docker run command line into container.options without removing flags act's flag set lacks; using newer Docker CLI flags against an older act version.","solutions":["Read the error detail: pflag reports the exact unknown/bad flag","Strip flags not needed for CI jobs (detached, tty, interactive) and keep resource/security opts","Check act's supported option flags (docker run-style: --cpus, --memory, --shm-size, --security-opt, --device, --volume, ...)","Update act — newer versions register more flags"],"exampleFix":"# before\noptions: --rm --name foo --cpus 2   # --rm/--name are managed by act itself\n\n# after\noptions: --cpus 2","handlingStrategy":"validation","validationCode":"# shell: every token must be a known docker-run flag or a value\ndocker run --rm $OPTIONS alpine true  # cheapest oracle for flag validity","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Strip lifecycle flags (--rm, -d, --name) — act manages the lifecycle","Copy only resource/security options into container.options","Re-check supported flags after upgrading act or Docker"],"tags":["docker","container-options","flag-parsing","workflow-config"],"backgroundTag":null,"analyzedSha":"4f411281417e88660bea1c1a1749aa71ae0bd60f","analyzedAt":"2026-08-15T09:19:46.307Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}