github.com/containerd/nerdctl@v1.7.7/pkg/api/types/container_types.go (about) 1 /* 2 Copyright The containerd Authors. 3 4 Licensed under the Apache License, Version 2.0 (the "License"); 5 you may not use this file except in compliance with the License. 6 You may obtain a copy of the License at 7 8 http://www.apache.org/licenses/LICENSE-2.0 9 10 Unless required by applicable law or agreed to in writing, software 11 distributed under the License is distributed on an "AS IS" BASIS, 12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 See the License for the specific language governing permissions and 14 limitations under the License. 15 */ 16 17 package types 18 19 import ( 20 "io" 21 "time" 22 ) 23 24 // ContainerStartOptions specifies options for the `nerdctl (container) start`. 25 type ContainerStartOptions struct { 26 Stdout io.Writer 27 // GOptions is the global options 28 GOptions GlobalCommandOptions 29 // Attach specifies whether to attach to the container's stdio. 30 Attach bool 31 // The key sequence for detaching a container. 32 DetachKeys string 33 } 34 35 // ContainerKillOptions specifies options for `nerdctl (container) kill`. 36 type ContainerKillOptions struct { 37 Stdout io.Writer 38 Stderr io.Writer 39 // GOptions is the global options 40 GOptions GlobalCommandOptions 41 // KillSignal is the signal to send to the container 42 KillSignal string 43 } 44 45 // ContainerCreateOptions specifies options for `nerdctl (container) create` and `nerdctl (container) run`. 46 type ContainerCreateOptions struct { 47 Stdout io.Writer 48 Stderr io.Writer 49 // GOptions is the global options 50 GOptions GlobalCommandOptions 51 52 // NerdctlCmd is the command name of nerdctl 53 NerdctlCmd string 54 // NerdctlArgs is the arguments of nerdctl 55 NerdctlArgs []string 56 57 // InRun is true when it's generated in the `run` command 58 InRun bool 59 60 // #region for basic flags 61 // Interactive keep STDIN open even if not attached 62 Interactive bool 63 // TTY specifies whether to allocate a pseudo-TTY for the container 64 TTY bool 65 // SigProxy specifies whether to proxy all received signals to the process 66 SigProxy bool 67 // Detach runs container in background and print container ID 68 Detach bool 69 // The key sequence for detaching a container. 70 DetachKeys string 71 // Attach STDIN, STDOUT, or STDERR 72 Attach []string 73 // Restart specifies the policy to apply when a container exits 74 Restart string 75 // Rm specifies whether to remove the container automatically when it exits 76 Rm bool 77 // Pull image before running, default is missing 78 Pull string 79 // Pid namespace to use 80 Pid string 81 // StopSignal signal to stop a container, default is SIGTERM 82 StopSignal string 83 // StopTimeout specifies the timeout (in seconds) to stop a container 84 StopTimeout int 85 // #endregion 86 87 // #region for platform flags 88 // Platform set target platform for build (e.g., "amd64", "arm64", "windows", "freebsd") 89 Platform string 90 // #endregion 91 92 // #region for init process flags 93 // InitProcessFlag specifies to run an init inside the container that forwards signals and reaps processes 94 InitProcessFlag bool 95 // InitBinary specifies the custom init binary to use, default is tini 96 InitBinary *string 97 // #endregion 98 99 // #region for isolation flags 100 // Isolation specifies the container isolation technology 101 Isolation string 102 // #endregion 103 104 // #region for resource flags 105 // CPUs specifies the number of CPUs 106 CPUs float64 107 // CPUQuota limits the CPU CFS (Completely Fair Scheduler) quota 108 CPUQuota int64 109 // CPUPeriod limits the CPU CFS (Completely Fair Scheduler) period 110 CPUPeriod uint64 111 // CPUShares specifies the CPU shares (relative weight) 112 CPUShares uint64 113 // CPUSetCPUs specifies the CPUs in which to allow execution (0-3, 0,1) 114 CPUSetCPUs string 115 // CPUSetMems specifies the memory nodes (MEMs) in which to allow execution (0-3, 0,1). Only effective on NUMA systems. 116 CPUSetMems string 117 // Memory specifies the memory limit 118 Memory string 119 // MemoryReservationChanged specifies whether the memory soft limit has been changed 120 MemoryReservationChanged bool 121 // MemoryReservation specifies the memory soft limit 122 MemoryReservation string 123 // MemorySwap specifies the swap limit equal to memory plus swap: '-1' to enable unlimited swap 124 MemorySwap string 125 // MemSwappinessChanged specifies whether the memory swappiness has been changed 126 MemorySwappiness64Changed bool 127 // MemorySwappiness64 specifies the tune container memory swappiness (0 to 100) (default -1) 128 MemorySwappiness64 int64 129 // KernelMemoryChanged specifies whether the kernel memory limit has been changed 130 KernelMemoryChanged bool 131 // KernelMemory specifies the kernel memory limit(deprecated) 132 KernelMemory string 133 // OomKillDisable specifies whether to disable OOM Killer 134 OomKillDisable bool 135 // OomScoreAdjChanged specifies whether the OOM preferences has been changed 136 OomScoreAdjChanged bool 137 // OomScoreAdj specifies the tune container’s OOM preferences (-1000 to 1000, rootless: 100 to 1000) 138 OomScoreAdj int 139 // PidsLimit specifies the tune container pids limit 140 PidsLimit int64 141 // CgroupConf specifies to configure cgroup v2 (key=value) 142 CgroupConf []string 143 // BlkioWeight specifies the block IO (relative weight), between 10 and 1000, or 0 to disable (default 0) 144 BlkioWeight uint16 145 // Cgroupns specifies the cgroup namespace to use 146 Cgroupns string 147 // CgroupParent specifies the optional parent cgroup for the container 148 CgroupParent string 149 // Device specifies add a host device to the container 150 Device []string 151 // #endregion 152 153 // #region for intel RDT flags 154 // RDTClass specifies the Intel Resource Director Technology (RDT) class 155 RDTClass string 156 // #endregion 157 158 // #region for user flags 159 // User specifies the user to run the container as 160 User string 161 // Umask specifies the umask to use for the container 162 Umask string 163 // GroupAdd specifies additional groups to join 164 GroupAdd []string 165 // #endregion 166 167 // #region for security flags 168 // SecurityOpt specifies security options 169 SecurityOpt []string 170 // CapAdd add Linux capabilities 171 CapAdd []string 172 // CapDrop drop Linux capabilities 173 CapDrop []string 174 // Privileged gives extended privileges to this container 175 Privileged bool 176 // #endregion 177 178 // #region for runtime flags 179 // Runtime to use for this container, e.g. "crun", or "io.containerd.runsc.v1". 180 Runtime string 181 // Sysctl set sysctl options, e.g "net.ipv4.ip_forward=1" 182 Sysctl []string 183 // #endregion 184 185 // #region for volume flags 186 // Volume specifies a list of volumes to mount 187 Volume []string 188 // Tmpfs specifies a list of tmpfs mounts 189 Tmpfs []string 190 // Mount specifies a list of mounts to mount 191 Mount []string 192 // VolumesFrom specifies a list of specified containers to mount from 193 VolumesFrom []string 194 // #endregion 195 196 // #region for rootfs flags 197 // ReadOnly mount the container's root filesystem as read only 198 ReadOnly bool 199 // Rootfs specifies the first argument is not an image but the rootfs to the exploded container. Corresponds to Podman CLI. 200 Rootfs bool 201 // #endregion 202 203 // #region for env flags 204 // EntrypointChanged specifies whether the entrypoint has been changed 205 EntrypointChanged bool 206 // Entrypoint overwrites the default ENTRYPOINT of the image 207 Entrypoint []string 208 // Workdir set the working directory for the container 209 Workdir string 210 // Env set environment variables 211 Env []string 212 // EnvFile set environment variables from file 213 EnvFile []string 214 // #endregion 215 216 // #region for metadata flags 217 // NameChanged specifies whether the name has been changed 218 NameChanged bool 219 // Name assign a name to the container 220 Name string 221 // Label set meta data on a container 222 Label []string 223 // LabelFile read in a line delimited file of labels 224 LabelFile []string 225 // CidFile write the container ID to the file 226 CidFile string 227 // PidFile specifies the file path to write the task's pid. The CLI syntax conforms to Podman convention. 228 PidFile string 229 // #endregion 230 231 // #region for logging flags 232 // LogDriver set the logging driver for the container 233 LogDriver string 234 // LogOpt set logging driver specific options 235 LogOpt []string 236 // #endregion 237 238 // #region for shared memory flags 239 // IPC namespace to use 240 IPC string 241 // ShmSize set the size of /dev/shm 242 ShmSize string 243 // #endregion 244 245 // #region for gpu flags 246 // GPUs specifies GPU devices to add to the container ('all' to pass all GPUs). Please see also ./gpu.md for details. 247 GPUs []string 248 // #endregion 249 250 // #region for ulimit flags 251 // Ulimit set ulimits 252 Ulimit []string 253 // #endregion 254 255 // #region for ipfs flags 256 // IPFSAddress specifies the multiaddr of IPFS API (default uses $IPFS_PATH env variable if defined or local directory ~/.ipfs) 257 IPFSAddress string 258 // #endregion 259 260 // ImagePullOpt specifies image pull options which holds the ImageVerifyOptions for verifying the image. 261 ImagePullOpt ImagePullOptions 262 } 263 264 // ContainerStopOptions specifies options for `nerdctl (container) stop`. 265 type ContainerStopOptions struct { 266 Stdout io.Writer 267 Stderr io.Writer 268 // GOptions is the global options 269 GOptions GlobalCommandOptions 270 // Timeout specifies how long to wait after sending a SIGTERM and before sending a SIGKILL. 271 // If it's nil, the default is 10 seconds. 272 Timeout *time.Duration 273 } 274 275 // ContainerRestartOptions specifies options for `nerdctl (container) restart`. 276 type ContainerRestartOptions struct { 277 Stdout io.Writer 278 GOption GlobalCommandOptions 279 // Time to wait after sending a SIGTERM and before sending a SIGKILL. 280 Timeout *time.Duration 281 } 282 283 // ContainerPauseOptions specifies options for `nerdctl (container) pause`. 284 type ContainerPauseOptions struct { 285 Stdout io.Writer 286 // GOptions is the global options 287 GOptions GlobalCommandOptions 288 } 289 290 // ContainerPruneOptions specifies options for `nerdctl (container) prune`. 291 type ContainerPruneOptions struct { 292 Stdout io.Writer 293 // GOptions is the global options 294 GOptions GlobalCommandOptions 295 } 296 297 // ContainerUnpauseOptions specifies options for `nerdctl (container) unpause`. 298 type ContainerUnpauseOptions ContainerPauseOptions 299 300 // ContainerRemoveOptions specifies options for `nerdctl (container) rm`. 301 type ContainerRemoveOptions struct { 302 Stdout io.Writer 303 // GOptions is the global options 304 GOptions GlobalCommandOptions 305 // Force enables to remove a running|paused|unknown container (uses SIGKILL) 306 Force bool 307 // Volumes removes anonymous volumes associated with the container 308 Volumes bool 309 } 310 311 // ContainerRenameOptions specifies options for `nerdctl (container) rename`. 312 type ContainerRenameOptions struct { 313 Stdout io.Writer 314 // GOptions is the global options 315 GOptions GlobalCommandOptions 316 } 317 318 // ContainerTopOptions specifies options for `nerdctl top`. 319 type ContainerTopOptions struct { 320 Stdout io.Writer 321 // GOptions is the global options 322 GOptions GlobalCommandOptions 323 } 324 325 // ContainerInspectOptions specifies options for `nerdctl container inspect` 326 type ContainerInspectOptions struct { 327 Stdout io.Writer 328 // GOptions is the global options 329 GOptions GlobalCommandOptions 330 // Format of the output 331 Format string 332 // Inspect mode, either dockercompat or native 333 Mode string 334 } 335 336 // ContainerCommitOptions specifies options for `nerdctl (container) commit`. 337 type ContainerCommitOptions struct { 338 Stdout io.Writer 339 // GOptions is the global options 340 GOptions GlobalCommandOptions 341 // Author (e.g., "nerdctl contributor <nerdctl-dev@example.com>") 342 Author string 343 // Commit message 344 Message string 345 // Apply Dockerfile instruction to the created image (supported directives: [CMD, ENTRYPOINT]) 346 Change []string 347 // Pause container during commit 348 Pause bool 349 } 350 351 // ContainerDiffOptions specifies options for `nerdctl (container) diff`. 352 type ContainerDiffOptions struct { 353 Stdout io.Writer 354 // GOptions is the global options 355 GOptions GlobalCommandOptions 356 } 357 358 // ContainerLogsOptions specifies options for `nerdctl (container) logs`. 359 type ContainerLogsOptions struct { 360 Stdout io.Writer 361 Stderr io.Writer 362 // GOptions is the global options. 363 GOptions GlobalCommandOptions 364 // Follow specifies whether to stream the logs or just print the existing logs. 365 Follow bool 366 // Timestamps specifies whether to show the timestamps of the logs. 367 Timestamps bool 368 // Tail specifies the number of lines to show from the end of the logs. 369 // Specify 0 to show all logs. 370 Tail uint 371 // Show logs since timestamp (e.g., 2013-01-02T13:23:37Z) or relative (e.g., 42m for 42 minutes). 372 Since string 373 // Show logs before a timestamp (e.g., 2013-01-02T13:23:37Z) or relative (e.g., 42m for 42 minutes). 374 Until string 375 } 376 377 // ContainerWaitOptions specifies options for `nerdctl (container) wait`. 378 type ContainerWaitOptions struct { 379 Stdout io.Writer 380 // GOptions is the global options. 381 GOptions GlobalCommandOptions 382 } 383 384 // ContainerAttachOptions specifies options for `nerdctl (container) attach`. 385 type ContainerAttachOptions struct { 386 Stdin io.Reader 387 Stdout io.Writer 388 Stderr io.Writer 389 390 // GOptions is the global options. 391 GOptions GlobalCommandOptions 392 // DetachKeys is the key sequences to detach from the container. 393 DetachKeys string 394 } 395 396 // ContainerExecOptions specifies options for `nerdctl (container) exec` 397 type ContainerExecOptions struct { 398 GOptions GlobalCommandOptions 399 // Allocate a pseudo-TTY 400 TTY bool 401 // Keep STDIN open even if not attached 402 Interactive bool 403 // Detached mode: run command in the background 404 Detach bool 405 // Working directory inside the container 406 Workdir string 407 // Set environment variables 408 Env []string 409 // Set environment variables from file 410 EnvFile []string 411 // Give extended privileges to the command 412 Privileged bool 413 // Username or UID (format: <name|uid>[:<group|gid>]) 414 User string 415 } 416 417 // ContainerListOptions specifies options for `nerdctl (container) list`. 418 type ContainerListOptions struct { 419 // GOptions is the global options. 420 GOptions GlobalCommandOptions 421 // Show all containers (default shows just running). 422 All bool 423 // Show n last created containers (includes all states). Non-positive values are ignored. 424 // In other words, if LastN is positive, All will be set to true. 425 LastN int 426 // Truncate output (e.g., container ID, command of the container main process, etc.) or not. 427 Truncate bool 428 // Display total file sizes. 429 Size bool 430 // Filters matches containers based on given conditions. 431 Filters []string 432 } 433 434 // ContainerCpOptions specifies options for `nerdctl (container) cp` 435 type ContainerCpOptions struct { 436 // GOptions is the global options. 437 GOptions GlobalCommandOptions 438 // ContainerReq is name, short ID, or long ID of container to copy to/from. 439 ContainerReq string 440 Container2Host bool 441 // Destination path to copy file to. 442 DestPath string 443 // Source path to copy file from. 444 SrcPath string 445 // Follow symbolic links in SRC_PATH 446 FollowSymLink bool 447 } 448 449 // ContainerStatsOptions specifies options for `nerdctl stats`. 450 type ContainerStatsOptions struct { 451 Stdout io.Writer 452 Stderr io.Writer 453 // GOptions is the global options. 454 GOptions GlobalCommandOptions 455 // Show all containers (default shows just running). 456 All bool 457 // Pretty-print images using a Go template, e.g., {{json .}}. 458 Format string 459 // Disable streaming stats and only pull the first result. 460 NoStream bool 461 // Do not truncate output. 462 NoTrunc bool 463 }