Skip to content

[Regression 2.4.0] ctr run treats container command flags as ctr flags ("flag provided but not defined") #14208

Closed

Description

@chenglongtang1

Description

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

  1. added theissue type on Sep 22, 2026
  2. added
    area/ctr
    on Sep 22, 2026
  3. added a commit that references this issue on Sep 23, 2026
    334d6da
  4. added a commit that references this issue on Sep 23, 2026
    2d0e534
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/ctrkind/bug

    Type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions