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

Function setCreateFlags

cmd/nerdctl/container/container_run.go:86–322  ·  view source on GitHub ↗
(cmd *cobra.Command)

Source from the content-addressed store, hash-verified

84}
85
86func setCreateFlags(cmd *cobra.Command) {
87
88 // No "-h" alias for "--help", because "-h" for "--hostname".
89 cmd.Flags().Bool("help", false, "show help")
90
91 cmd.Flags().BoolP("tty", "t", false, "Allocate a pseudo-TTY")
92 cmd.Flags().Bool("sig-proxy", true, "Proxy received signals to the process")
93 cmd.Flags().BoolP("interactive", "i", false, "Keep STDIN open even if not attached")
94 cmd.Flags().String("restart", "no", `Restart policy to apply when a container exits (implemented values: "no"|"always|on-failure:n|unless-stopped")`)
95 cmd.RegisterFlagCompletionFunc("restart", func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
96 return []string{"no", "always", "on-failure", "unless-stopped"}, cobra.ShellCompDirectiveNoFileComp
97 })
98 cmd.Flags().Bool("rm", false, "Automatically remove the container when it exits")
99 cmd.Flags().String("pull", "missing", `Pull image before running ("always"|"missing"|"never")`)
100 cmd.Flags().BoolP("quiet", "q", false, "Suppress the pull output")
101 cmd.RegisterFlagCompletionFunc("pull", func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
102 return []string{"always", "missing", "never"}, cobra.ShellCompDirectiveNoFileComp
103 })
104 cmd.Flags().String("stop-signal", "SIGTERM", "Signal to stop a container")
105 cmd.Flags().Int("stop-timeout", 0, "Timeout (in seconds) to stop a container")
106 cmd.Flags().String("detach-keys", consoleutil.DefaultDetachKeys, "Override the default detach keys")
107
108 // #region for init process
109 cmd.Flags().Bool("init", false, "Run an init process inside the container, Default to use tini")
110 cmd.Flags().String("init-binary", tiniInitBinary, "The custom binary to use as the init process")
111 // #endregion
112
113 // #region platform flags
114 cmd.Flags().String("platform", "", "Set platform (e.g. \"amd64\", \"arm64\")") // not a slice, and there is no --all-platforms
115 cmd.RegisterFlagCompletionFunc("platform", completion.Platforms)
116 // #endregion
117
118 // #region network flags
119 // network (net) is defined as StringSlice, not StringArray, to allow specifying "--network=cni1,cni2"
120 cmd.Flags().StringSlice("network", []string{netutil.DefaultNetworkName}, `Connect a container to a network ("bridge"|"host"|"none"|"container:<container>"|"ns:<path>"|<CNI>)`)
121 cmd.RegisterFlagCompletionFunc("network", func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
122 return completion.NetworkNames(cmd, []string{})
123 })
124 cmd.Flags().StringSlice("net", []string{netutil.DefaultNetworkName}, `Connect a container to a network ("bridge"|"host"|"none"|"container:<container>"|"ns:<path>"|<CNI>)`)
125 cmd.RegisterFlagCompletionFunc("net", func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
126 return completion.NetworkNames(cmd, []string{})
127 })
128 // dns is defined as StringSlice, not StringArray, to allow specifying "--dns=1.1.1.1,8.8.8.8" (compatible with Podman)
129 cmd.Flags().StringSlice("dns", nil, "Set custom DNS servers")
130 cmd.Flags().StringSlice("dns-search", nil, "Set custom DNS search domains")
131 // We allow for both "--dns-opt" and "--dns-option", although the latter is the recommended way.
132 cmd.Flags().StringSlice("dns-opt", nil, "Set DNS options")
133 cmd.Flags().StringSlice("dns-option", nil, "Set DNS options")
134 // publish is defined as StringSlice, not StringArray, to allow specifying "--publish=80:80,443:443" (compatible with Podman)
135 cmd.Flags().StringSliceP("publish", "p", nil, "Publish a container's port(s) to the host")
136 cmd.Flags().String("ip", "", "IPv4 address to assign to the container")
137 cmd.Flags().String("ip6", "", "IPv6 address to assign to the container")
138 cmd.Flags().StringP("hostname", "h", "", "Container host name")
139 cmd.Flags().String("domainname", "", "Container domain name")
140 cmd.Flags().String("mac-address", "", "MAC address to assign to the container")
141 // #endregion
142
143 cmd.Flags().String("ipc", "", `IPC namespace to use ("host"|"private"|"shareable"|"container:<container>")`)

Callers 2

CreateCommandFunction · 0.85
RunCommandFunction · 0.85

Calls 5

NetworkNamesFunction · 0.92
ContainerNamesFunction · 0.92
CgroupnsModeFunction · 0.92
DriversFunction · 0.92
StringMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…