You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Regression 2.4.0] ctr run treats container command flags as ctr flags ("flag provided but not defined") #14208
In containerd 2.4.0, passing container command arguments that begin with a dash (such as bash -uexc "..." or sh -c "...") causes ctr run to fail with flag provided but not defined.
In all previous versions of containerd (containerd 1.7.x and 2.0.x through 2.3.x), ctr run [flags] Image|RootFS ID [COMMAND] [ARG...] treated all arguments following <ID> as the container process command and arguments. In 2.4.0, ctr scans for its own flags across and after positional arguments.
Steps to Reproduce
Run any container where the command to execute inside the container includes flags:
ctr run --rm docker.io/library/busybox:latest test-container sh -uexc "echo hello"
Expected Behavior (containerd <= 2.3.x)
The arguments sh, -uexc, and "echo hello" are passed to the container runtime via oci.WithProcessArgs. The container executes the command and exits cleanly:
+ echo hello
hello
Actual Behavior (containerd 2.4.0)
ctr attempts to parse -uexc as a flag for ctr run itself and aborts:
Incorrect Usage: flag provided but not defined: -uexc
ctr: flag provided but not defined: -uexc
Additional Context & Impact
Regression source: This behavior changed with the CLI migration from urfave/cli/v2 to urfave/cli/v3 in 2.4.0. In v2, Go's standard library flag.FlagSet stopped flag parsing at the first positional argument (Image), leaving all subsequent arguments untouched in c.Args().Slice()[2:]. In v3, the argument scanner continues looking for flags throughout the remaining arguments.
Compatibility impact with --: Existing scripts and automation cannot simply insert -- after the container ID (ctr run <image> <id> -- <cmd>) to support both old and new versions. In containerd <= 2.3.x, ctr does not strip -- when placed after positional arguments; it passes "--" directly to runc as the process command, failing with:
exec: "--": executable file not found in $PATH
This also affects other commands taking positional container commands, such as ctr exec.
Activity
ctr: stop flag parsing before container command
ctr: stop flag parsing before container command