MCPcopy Create free account
hub / github.com/containerd/nerdctl / ExecCommand

Function ExecCommand

cmd/nerdctl/container/container_exec.go:33–56  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

31)
32
33func ExecCommand() *cobra.Command {
34 var cmd = &cobra.Command{
35 Use: "exec [flags] CONTAINER COMMAND [ARG...]",
36 Args: cobra.MinimumNArgs(2),
37 Short: "Run a command in a running container",
38 RunE: execAction,
39 ValidArgsFunction: execShellComplete,
40 SilenceUsage: true,
41 SilenceErrors: true,
42 }
43 cmd.Flags().SetInterspersed(false)
44
45 cmd.Flags().BoolP("tty", "t", false, "Allocate a pseudo-TTY")
46 cmd.Flags().BoolP("interactive", "i", false, "Keep STDIN open even if not attached")
47 cmd.Flags().BoolP("detach", "d", false, "Detached mode: run command in the background")
48 cmd.Flags().StringP("workdir", "w", "", "Working directory inside the container")
49 // env needs to be StringArray, not StringSlice, to prevent "FOO=foo1,foo2" from being split to {"FOO=foo1", "foo2"}
50 cmd.Flags().StringArrayP("env", "e", nil, "Set environment variables")
51 // env-file is defined as StringSlice, not StringArray, to allow specifying "--env-file=FILE1,FILE2" (compatible with Podman)
52 cmd.Flags().StringSlice("env-file", nil, "Set environment variables from file")
53 cmd.Flags().Bool("privileged", false, "Give extended privileges to the command")
54 cmd.Flags().StringP("user", "u", "", "Username or UID (format: <name|uid>[:<group|gid>])")
55 return cmd
56}
57
58func execOptions(cmd *cobra.Command) (types.ContainerExecOptions, error) {
59 // We do not check if we have a terminal here, as container.Exec calling console.Current will ensure that

Callers 2

newAppFunction · 0.92
CommandFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…