github.com/docker/engine@v22.0.0-20211208180946-d456264580cf+incompatible/api/types/types.go (about) 1 package types // import "github.com/docker/docker/api/types" 2 3 import ( 4 "errors" 5 "fmt" 6 "io" 7 "os" 8 "strings" 9 "time" 10 11 "github.com/docker/docker/api/types/container" 12 "github.com/docker/docker/api/types/filters" 13 "github.com/docker/docker/api/types/mount" 14 "github.com/docker/docker/api/types/network" 15 "github.com/docker/docker/api/types/registry" 16 "github.com/docker/docker/api/types/swarm" 17 "github.com/docker/go-connections/nat" 18 ) 19 20 // RootFS returns Image's RootFS description including the layer IDs. 21 type RootFS struct { 22 Type string 23 Layers []string `json:",omitempty"` 24 BaseLayer string `json:",omitempty"` 25 } 26 27 // ImageInspect contains response of Engine API: 28 // GET "/images/{name:.*}/json" 29 type ImageInspect struct { 30 ID string `json:"Id"` 31 RepoTags []string 32 RepoDigests []string 33 Parent string 34 Comment string 35 Created string 36 Container string 37 ContainerConfig *container.Config 38 DockerVersion string 39 Author string 40 Config *container.Config 41 Architecture string 42 Variant string `json:",omitempty"` 43 Os string 44 OsVersion string `json:",omitempty"` 45 Size int64 46 VirtualSize int64 47 GraphDriver GraphDriverData 48 RootFS RootFS 49 Metadata ImageMetadata 50 } 51 52 // ImageMetadata contains engine-local data about the image 53 type ImageMetadata struct { 54 LastTagTime time.Time `json:",omitempty"` 55 } 56 57 // Container contains response of Engine API: 58 // GET "/containers/json" 59 type Container struct { 60 ID string `json:"Id"` 61 Names []string 62 Image string 63 ImageID string 64 Command string 65 Created int64 66 Ports []Port 67 SizeRw int64 `json:",omitempty"` 68 SizeRootFs int64 `json:",omitempty"` 69 Labels map[string]string 70 State string 71 Status string 72 HostConfig struct { 73 NetworkMode string `json:",omitempty"` 74 } 75 NetworkSettings *SummaryNetworkSettings 76 Mounts []MountPoint 77 } 78 79 // CopyConfig contains request body of Engine API: 80 // POST "/containers/"+containerID+"/copy" 81 type CopyConfig struct { 82 Resource string 83 } 84 85 // ContainerPathStat is used to encode the header from 86 // GET "/containers/{name:.*}/archive" 87 // "Name" is the file or directory name. 88 type ContainerPathStat struct { 89 Name string `json:"name"` 90 Size int64 `json:"size"` 91 Mode os.FileMode `json:"mode"` 92 Mtime time.Time `json:"mtime"` 93 LinkTarget string `json:"linkTarget"` 94 } 95 96 // ContainerStats contains response of Engine API: 97 // GET "/stats" 98 type ContainerStats struct { 99 Body io.ReadCloser `json:"body"` 100 OSType string `json:"ostype"` 101 } 102 103 // Ping contains response of Engine API: 104 // GET "/_ping" 105 type Ping struct { 106 APIVersion string 107 OSType string 108 Experimental bool 109 BuilderVersion BuilderVersion 110 } 111 112 // ComponentVersion describes the version information for a specific component. 113 type ComponentVersion struct { 114 Name string 115 Version string 116 Details map[string]string `json:",omitempty"` 117 } 118 119 // Version contains response of Engine API: 120 // GET "/version" 121 type Version struct { 122 Platform struct{ Name string } `json:",omitempty"` 123 Components []ComponentVersion `json:",omitempty"` 124 125 // The following fields are deprecated, they relate to the Engine component and are kept for backwards compatibility 126 127 Version string 128 APIVersion string `json:"ApiVersion"` 129 MinAPIVersion string `json:"MinAPIVersion,omitempty"` 130 GitCommit string 131 GoVersion string 132 Os string 133 Arch string 134 KernelVersion string `json:",omitempty"` 135 Experimental bool `json:",omitempty"` 136 BuildTime string `json:",omitempty"` 137 } 138 139 // Commit holds the Git-commit (SHA1) that a binary was built from, as reported 140 // in the version-string of external tools, such as containerd, or runC. 141 type Commit struct { 142 ID string // ID is the actual commit ID of external tool. 143 Expected string // Expected is the commit ID of external tool expected by dockerd as set at build time. 144 } 145 146 // Info contains response of Engine API: 147 // GET "/info" 148 type Info struct { 149 ID string 150 Containers int 151 ContainersRunning int 152 ContainersPaused int 153 ContainersStopped int 154 Images int 155 Driver string 156 DriverStatus [][2]string 157 SystemStatus [][2]string `json:",omitempty"` // SystemStatus is only propagated by the Swarm standalone API 158 Plugins PluginsInfo 159 MemoryLimit bool 160 SwapLimit bool 161 KernelMemory bool // Deprecated: kernel 5.4 deprecated kmem.limit_in_bytes 162 KernelMemoryTCP bool 163 CPUCfsPeriod bool `json:"CpuCfsPeriod"` 164 CPUCfsQuota bool `json:"CpuCfsQuota"` 165 CPUShares bool 166 CPUSet bool 167 PidsLimit bool 168 IPv4Forwarding bool 169 BridgeNfIptables bool 170 BridgeNfIP6tables bool `json:"BridgeNfIp6tables"` 171 Debug bool 172 NFd int 173 OomKillDisable bool 174 NGoroutines int 175 SystemTime string 176 LoggingDriver string 177 CgroupDriver string 178 CgroupVersion string `json:",omitempty"` 179 NEventsListener int 180 KernelVersion string 181 OperatingSystem string 182 OSVersion string 183 OSType string 184 Architecture string 185 IndexServerAddress string 186 RegistryConfig *registry.ServiceConfig 187 NCPU int 188 MemTotal int64 189 GenericResources []swarm.GenericResource 190 DockerRootDir string 191 HTTPProxy string `json:"HttpProxy"` 192 HTTPSProxy string `json:"HttpsProxy"` 193 NoProxy string 194 Name string 195 Labels []string 196 ExperimentalBuild bool 197 ServerVersion string 198 ClusterStore string `json:",omitempty"` // Deprecated: host-discovery and overlay networks with external k/v stores are deprecated 199 ClusterAdvertise string `json:",omitempty"` // Deprecated: host-discovery and overlay networks with external k/v stores are deprecated 200 Runtimes map[string]Runtime 201 DefaultRuntime string 202 Swarm swarm.Info 203 // LiveRestoreEnabled determines whether containers should be kept 204 // running when the daemon is shutdown or upon daemon start if 205 // running containers are detected 206 LiveRestoreEnabled bool 207 Isolation container.Isolation 208 InitBinary string 209 ContainerdCommit Commit 210 RuncCommit Commit 211 InitCommit Commit 212 SecurityOptions []string 213 ProductLicense string `json:",omitempty"` 214 DefaultAddressPools []NetworkAddressPool `json:",omitempty"` 215 216 // Warnings contains a slice of warnings that occurred while collecting 217 // system information. These warnings are intended to be informational 218 // messages for the user, and are not intended to be parsed / used for 219 // other purposes, as they do not have a fixed format. 220 Warnings []string 221 } 222 223 // KeyValue holds a key/value pair 224 type KeyValue struct { 225 Key, Value string 226 } 227 228 // NetworkAddressPool is a temp struct used by Info struct 229 type NetworkAddressPool struct { 230 Base string 231 Size int 232 } 233 234 // SecurityOpt contains the name and options of a security option 235 type SecurityOpt struct { 236 Name string 237 Options []KeyValue 238 } 239 240 // DecodeSecurityOptions decodes a security options string slice to a type safe 241 // SecurityOpt 242 func DecodeSecurityOptions(opts []string) ([]SecurityOpt, error) { 243 so := []SecurityOpt{} 244 for _, opt := range opts { 245 // support output from a < 1.13 docker daemon 246 if !strings.Contains(opt, "=") { 247 so = append(so, SecurityOpt{Name: opt}) 248 continue 249 } 250 secopt := SecurityOpt{} 251 split := strings.Split(opt, ",") 252 for _, s := range split { 253 kv := strings.SplitN(s, "=", 2) 254 if len(kv) != 2 { 255 return nil, fmt.Errorf("invalid security option %q", s) 256 } 257 if kv[0] == "" || kv[1] == "" { 258 return nil, errors.New("invalid empty security option") 259 } 260 if kv[0] == "name" { 261 secopt.Name = kv[1] 262 continue 263 } 264 secopt.Options = append(secopt.Options, KeyValue{Key: kv[0], Value: kv[1]}) 265 } 266 so = append(so, secopt) 267 } 268 return so, nil 269 } 270 271 // PluginsInfo is a temp struct holding Plugins name 272 // registered with docker daemon. It is used by Info struct 273 type PluginsInfo struct { 274 // List of Volume plugins registered 275 Volume []string 276 // List of Network plugins registered 277 Network []string 278 // List of Authorization plugins registered 279 Authorization []string 280 // List of Log plugins registered 281 Log []string 282 } 283 284 // ExecStartCheck is a temp struct used by execStart 285 // Config fields is part of ExecConfig in runconfig package 286 type ExecStartCheck struct { 287 // ExecStart will first check if it's detached 288 Detach bool 289 // Check if there's a tty 290 Tty bool 291 } 292 293 // HealthcheckResult stores information about a single run of a healthcheck probe 294 type HealthcheckResult struct { 295 Start time.Time // Start is the time this check started 296 End time.Time // End is the time this check ended 297 ExitCode int // ExitCode meanings: 0=healthy, 1=unhealthy, 2=reserved (considered unhealthy), else=error running probe 298 Output string // Output from last check 299 } 300 301 // Health states 302 const ( 303 NoHealthcheck = "none" // Indicates there is no healthcheck 304 Starting = "starting" // Starting indicates that the container is not yet ready 305 Healthy = "healthy" // Healthy indicates that the container is running correctly 306 Unhealthy = "unhealthy" // Unhealthy indicates that the container has a problem 307 ) 308 309 // Health stores information about the container's healthcheck results 310 type Health struct { 311 Status string // Status is one of Starting, Healthy or Unhealthy 312 FailingStreak int // FailingStreak is the number of consecutive failures 313 Log []*HealthcheckResult // Log contains the last few results (oldest first) 314 } 315 316 // ContainerState stores container's running state 317 // it's part of ContainerJSONBase and will return by "inspect" command 318 type ContainerState struct { 319 Status string // String representation of the container state. Can be one of "created", "running", "paused", "restarting", "removing", "exited", or "dead" 320 Running bool 321 Paused bool 322 Restarting bool 323 OOMKilled bool 324 Dead bool 325 Pid int 326 ExitCode int 327 Error string 328 StartedAt string 329 FinishedAt string 330 Health *Health `json:",omitempty"` 331 } 332 333 // ContainerNode stores information about the node that a container 334 // is running on. It's only used by the Docker Swarm standalone API 335 type ContainerNode struct { 336 ID string 337 IPAddress string `json:"IP"` 338 Addr string 339 Name string 340 Cpus int 341 Memory int64 342 Labels map[string]string 343 } 344 345 // ContainerJSONBase contains response of Engine API: 346 // GET "/containers/{name:.*}/json" 347 type ContainerJSONBase struct { 348 ID string `json:"Id"` 349 Created string 350 Path string 351 Args []string 352 State *ContainerState 353 Image string 354 ResolvConfPath string 355 HostnamePath string 356 HostsPath string 357 LogPath string 358 Node *ContainerNode `json:",omitempty"` // Node is only propagated by Docker Swarm standalone API 359 Name string 360 RestartCount int 361 Driver string 362 Platform string 363 MountLabel string 364 ProcessLabel string 365 AppArmorProfile string 366 ExecIDs []string 367 HostConfig *container.HostConfig 368 GraphDriver GraphDriverData 369 SizeRw *int64 `json:",omitempty"` 370 SizeRootFs *int64 `json:",omitempty"` 371 } 372 373 // ContainerJSON is newly used struct along with MountPoint 374 type ContainerJSON struct { 375 *ContainerJSONBase 376 Mounts []MountPoint 377 Config *container.Config 378 NetworkSettings *NetworkSettings 379 } 380 381 // NetworkSettings exposes the network settings in the api 382 type NetworkSettings struct { 383 NetworkSettingsBase 384 DefaultNetworkSettings 385 Networks map[string]*network.EndpointSettings 386 } 387 388 // SummaryNetworkSettings provides a summary of container's networks 389 // in /containers/json 390 type SummaryNetworkSettings struct { 391 Networks map[string]*network.EndpointSettings 392 } 393 394 // NetworkSettingsBase holds basic information about networks 395 type NetworkSettingsBase struct { 396 Bridge string // Bridge is the Bridge name the network uses(e.g. `docker0`) 397 SandboxID string // SandboxID uniquely represents a container's network stack 398 HairpinMode bool // HairpinMode specifies if hairpin NAT should be enabled on the virtual interface 399 LinkLocalIPv6Address string // LinkLocalIPv6Address is an IPv6 unicast address using the link-local prefix 400 LinkLocalIPv6PrefixLen int // LinkLocalIPv6PrefixLen is the prefix length of an IPv6 unicast address 401 Ports nat.PortMap // Ports is a collection of PortBinding indexed by Port 402 SandboxKey string // SandboxKey identifies the sandbox 403 SecondaryIPAddresses []network.Address 404 SecondaryIPv6Addresses []network.Address 405 } 406 407 // DefaultNetworkSettings holds network information 408 // during the 2 release deprecation period. 409 // It will be removed in Docker 1.11. 410 type DefaultNetworkSettings struct { 411 EndpointID string // EndpointID uniquely represents a service endpoint in a Sandbox 412 Gateway string // Gateway holds the gateway address for the network 413 GlobalIPv6Address string // GlobalIPv6Address holds network's global IPv6 address 414 GlobalIPv6PrefixLen int // GlobalIPv6PrefixLen represents mask length of network's global IPv6 address 415 IPAddress string // IPAddress holds the IPv4 address for the network 416 IPPrefixLen int // IPPrefixLen represents mask length of network's IPv4 address 417 IPv6Gateway string // IPv6Gateway holds gateway address specific for IPv6 418 MacAddress string // MacAddress holds the MAC address for the network 419 } 420 421 // MountPoint represents a mount point configuration inside the container. 422 // This is used for reporting the mountpoints in use by a container. 423 type MountPoint struct { 424 Type mount.Type `json:",omitempty"` 425 Name string `json:",omitempty"` 426 Source string 427 Destination string 428 Driver string `json:",omitempty"` 429 Mode string 430 RW bool 431 Propagation mount.Propagation 432 } 433 434 // NetworkResource is the body of the "get network" http response message 435 type NetworkResource struct { 436 Name string // Name is the requested name of the network 437 ID string `json:"Id"` // ID uniquely identifies a network on a single machine 438 Created time.Time // Created is the time the network created 439 Scope string // Scope describes the level at which the network exists (e.g. `swarm` for cluster-wide or `local` for machine level) 440 Driver string // Driver is the Driver name used to create the network (e.g. `bridge`, `overlay`) 441 EnableIPv6 bool // EnableIPv6 represents whether to enable IPv6 442 IPAM network.IPAM // IPAM is the network's IP Address Management 443 Internal bool // Internal represents if the network is used internal only 444 Attachable bool // Attachable represents if the global scope is manually attachable by regular containers from workers in swarm mode. 445 Ingress bool // Ingress indicates the network is providing the routing-mesh for the swarm cluster. 446 ConfigFrom network.ConfigReference // ConfigFrom specifies the source which will provide the configuration for this network. 447 ConfigOnly bool // ConfigOnly networks are place-holder networks for network configurations to be used by other networks. ConfigOnly networks cannot be used directly to run containers or services. 448 Containers map[string]EndpointResource // Containers contains endpoints belonging to the network 449 Options map[string]string // Options holds the network specific options to use for when creating the network 450 Labels map[string]string // Labels holds metadata specific to the network being created 451 Peers []network.PeerInfo `json:",omitempty"` // List of peer nodes for an overlay network 452 Services map[string]network.ServiceInfo `json:",omitempty"` 453 } 454 455 // EndpointResource contains network resources allocated and used for a container in a network 456 type EndpointResource struct { 457 Name string 458 EndpointID string 459 MacAddress string 460 IPv4Address string 461 IPv6Address string 462 } 463 464 // NetworkCreate is the expected body of the "create network" http request message 465 type NetworkCreate struct { 466 // Check for networks with duplicate names. 467 // Network is primarily keyed based on a random ID and not on the name. 468 // Network name is strictly a user-friendly alias to the network 469 // which is uniquely identified using ID. 470 // And there is no guaranteed way to check for duplicates. 471 // Option CheckDuplicate is there to provide a best effort checking of any networks 472 // which has the same name but it is not guaranteed to catch all name collisions. 473 CheckDuplicate bool 474 Driver string 475 Scope string 476 EnableIPv6 bool 477 IPAM *network.IPAM 478 Internal bool 479 Attachable bool 480 Ingress bool 481 ConfigOnly bool 482 ConfigFrom *network.ConfigReference 483 Options map[string]string 484 Labels map[string]string 485 } 486 487 // NetworkCreateRequest is the request message sent to the server for network create call. 488 type NetworkCreateRequest struct { 489 NetworkCreate 490 Name string 491 } 492 493 // NetworkCreateResponse is the response message sent by the server for network create call 494 type NetworkCreateResponse struct { 495 ID string `json:"Id"` 496 Warning string 497 } 498 499 // NetworkConnect represents the data to be used to connect a container to the network 500 type NetworkConnect struct { 501 Container string 502 EndpointConfig *network.EndpointSettings `json:",omitempty"` 503 } 504 505 // NetworkDisconnect represents the data to be used to disconnect a container from the network 506 type NetworkDisconnect struct { 507 Container string 508 Force bool 509 } 510 511 // NetworkInspectOptions holds parameters to inspect network 512 type NetworkInspectOptions struct { 513 Scope string 514 Verbose bool 515 } 516 517 // Checkpoint represents the details of a checkpoint 518 type Checkpoint struct { 519 Name string // Name is the name of the checkpoint 520 } 521 522 // Runtime describes an OCI runtime 523 type Runtime struct { 524 Path string `json:"path"` 525 Args []string `json:"runtimeArgs,omitempty"` 526 527 // This is exposed here only for internal use 528 // It is not currently supported to specify custom shim configs 529 Shim *ShimConfig `json:"-"` 530 } 531 532 // ShimConfig is used by runtime to configure containerd shims 533 type ShimConfig struct { 534 Binary string 535 Opts interface{} 536 } 537 538 // DiskUsageObject represents an object type used for disk usage query filtering. 539 type DiskUsageObject string 540 541 const ( 542 // ContainerObject represents a container DiskUsageObject. 543 ContainerObject DiskUsageObject = "container" 544 // ImageObject represents an image DiskUsageObject. 545 ImageObject DiskUsageObject = "image" 546 // VolumeObject represents a volume DiskUsageObject. 547 VolumeObject DiskUsageObject = "volume" 548 // BuildCacheObject represents a build-cache DiskUsageObject. 549 BuildCacheObject DiskUsageObject = "build-cache" 550 ) 551 552 // DiskUsageOptions holds parameters for system disk usage query. 553 type DiskUsageOptions struct { 554 // Types specifies what object types to include in the response. If empty, 555 // all object types are returned. 556 Types []DiskUsageObject 557 } 558 559 // DiskUsage contains response of Engine API: 560 // GET "/system/df" 561 type DiskUsage struct { 562 LayersSize int64 563 Images []*ImageSummary 564 Containers []*Container 565 Volumes []*Volume 566 BuildCache []*BuildCache 567 BuilderSize int64 `json:",omitempty"` // Deprecated: deprecated in API 1.38, and no longer used since API 1.40. 568 } 569 570 // ContainersPruneReport contains the response for Engine API: 571 // POST "/containers/prune" 572 type ContainersPruneReport struct { 573 ContainersDeleted []string 574 SpaceReclaimed uint64 575 } 576 577 // VolumesPruneReport contains the response for Engine API: 578 // POST "/volumes/prune" 579 type VolumesPruneReport struct { 580 VolumesDeleted []string 581 SpaceReclaimed uint64 582 } 583 584 // ImagesPruneReport contains the response for Engine API: 585 // POST "/images/prune" 586 type ImagesPruneReport struct { 587 ImagesDeleted []ImageDeleteResponseItem 588 SpaceReclaimed uint64 589 } 590 591 // BuildCachePruneReport contains the response for Engine API: 592 // POST "/build/prune" 593 type BuildCachePruneReport struct { 594 CachesDeleted []string 595 SpaceReclaimed uint64 596 } 597 598 // NetworksPruneReport contains the response for Engine API: 599 // POST "/networks/prune" 600 type NetworksPruneReport struct { 601 NetworksDeleted []string 602 } 603 604 // SecretCreateResponse contains the information returned to a client 605 // on the creation of a new secret. 606 type SecretCreateResponse struct { 607 // ID is the id of the created secret. 608 ID string 609 } 610 611 // SecretListOptions holds parameters to list secrets 612 type SecretListOptions struct { 613 Filters filters.Args 614 } 615 616 // ConfigCreateResponse contains the information returned to a client 617 // on the creation of a new config. 618 type ConfigCreateResponse struct { 619 // ID is the id of the created config. 620 ID string 621 } 622 623 // ConfigListOptions holds parameters to list configs 624 type ConfigListOptions struct { 625 Filters filters.Args 626 } 627 628 // PushResult contains the tag, manifest digest, and manifest size from the 629 // push. It's used to signal this information to the trust code in the client 630 // so it can sign the manifest if necessary. 631 type PushResult struct { 632 Tag string 633 Digest string 634 Size int 635 } 636 637 // BuildResult contains the image id of a successful build 638 type BuildResult struct { 639 ID string 640 } 641 642 // BuildCache contains information about a build cache record 643 type BuildCache struct { 644 ID string 645 Parent string 646 Type string 647 Description string 648 InUse bool 649 Shared bool 650 Size int64 651 CreatedAt time.Time 652 LastUsedAt *time.Time 653 UsageCount int 654 } 655 656 // BuildCachePruneOptions hold parameters to prune the build cache 657 type BuildCachePruneOptions struct { 658 All bool 659 KeepStorage int64 660 Filters filters.Args 661 }