diff --git a/cmd/ctr/commands/oci/oci.go b/cmd/ctr/commands/oci/oci.go index cbd64fee3..45251314c 100644 --- a/cmd/ctr/commands/oci/oci.go +++ b/cmd/ctr/commands/oci/oci.go @@ -24,6 +24,7 @@ import ( "github.com/containerd/containerd/cmd/ctr/commands" "github.com/containerd/containerd/containers" "github.com/containerd/containerd/oci" + "github.com/containerd/containerd/platforms" ) // Command is the parent for all OCI related tools under 'oci' @@ -38,11 +39,22 @@ var Command = cli.Command{ var defaultSpecCommand = cli.Command{ Name: "spec", Usage: "see the output of the default OCI spec", + Flags: []cli.Flag{ + cli.StringFlag{ + Name: "platform", + Usage: "platform of the spec to print (Examples: 'linux/arm64', 'windows/amd64')", + }, + }, Action: func(context *cli.Context) error { ctx, cancel := commands.AppContext(context) defer cancel() - spec, err := oci.GenerateSpec(ctx, nil, &containers.Container{}) + platform := platforms.DefaultString() + if plat := context.String("platform"); plat != "" { + platform = plat + } + + spec, err := oci.GenerateSpecWithPlatform(ctx, nil, platform, &containers.Container{}) if err != nil { return fmt.Errorf("failed to generate spec: %w", err) }