github.com/rish1988/moby@v25.0.2+incompatible/api/types/types.go (about) 1 package types // import "github.com/docker/docker/api/types" 2 3 import ( 4 "io" 5 "os" 6 "time" 7 8 "github.com/docker/docker/api/types/container" 9 "github.com/docker/docker/api/types/filters" 10 "github.com/docker/docker/api/types/image" 11 "github.com/docker/docker/api/types/mount" 12 "github.com/docker/docker/api/types/network" 13 "github.com/docker/docker/api/types/swarm" 14 "github.com/docker/docker/api/types/volume" 15 "github.com/docker/go-connections/nat" 16 ) 17 18 const ( 19 // MediaTypeRawStream is vendor specific MIME-Type set for raw TTY streams 20 MediaTypeRawStream = "application/vnd.docker.raw-stream" 21 22 // MediaTypeMultiplexedStream is vendor specific MIME-Type set for stdin/stdout/stderr multiplexed streams 23 MediaTypeMultiplexedStream = "application/vnd.docker.multiplexed-stream" 24 ) 25 26 // RootFS returns Image's RootFS description including the layer IDs. 27 type RootFS struct { 28 Type string `json:",omitempty"` 29 Layers []string `json:",omitempty"` 30 } 31 32 // ImageInspect contains response of Engine API: 33 // GET "/images/{name:.*}/json" 34 type ImageInspect struct { 35 // ID is the content-addressable ID of an image. 36 // 37 // This identifier is a content-addressable digest calculated from the 38 // image's configuration (which includes the digests of layers used by 39 // the image). 40 // 41 // Note that this digest differs from the `RepoDigests` below, which 42 // holds digests of image manifests that reference the image. 43 ID string `json:"Id"` 44 45 // RepoTags is a list of image names/tags in the local image cache that 46 // reference this image. 47 // 48 // Multiple image tags can refer to the same image, and this list may be 49 // empty if no tags reference the image, in which case the image is 50 // "untagged", in which case it can still be referenced by its ID. 51 RepoTags []string 52 53 // RepoDigests is a list of content-addressable digests of locally available 54 // image manifests that the image is referenced from. Multiple manifests can 55 // refer to the same image. 56 // 57 // These digests are usually only available if the image was either pulled 58 // from a registry, or if the image was pushed to a registry, which is when 59 // the manifest is generated and its digest calculated. 60 RepoDigests []string 61 62 // Parent is the ID of the parent image. 63 // 64 // Depending on how the image was created, this field may be empty and 65 // is only set for images that were built/created locally. This field 66 // is empty if the image was pulled from an image registry. 67 Parent string 68 69 // Comment is an optional message that can be set when committing or 70 // importing the image. 71 Comment string 72 73 // Created is the date and time at which the image was created, formatted in 74 // RFC 3339 nano-seconds (time.RFC3339Nano). 75 Created string 76 77 // Container is the ID of the container that was used to create the image. 78 // 79 // Depending on how the image was created, this field may be empty. 80 // 81 // Deprecated: this field is omitted in API v1.45, but kept for backward compatibility. 82 Container string 83 84 // ContainerConfig is an optional field containing the configuration of the 85 // container that was last committed when creating the image. 86 // 87 // Previous versions of Docker builder used this field to store build cache, 88 // and it is not in active use anymore. 89 // 90 // Deprecated: this field is omitted in API v1.45, but kept for backward compatibility. 91 ContainerConfig *container.Config 92 93 // DockerVersion is the version of Docker that was used to build the image. 94 // 95 // Depending on how the image was created, this field may be empty. 96 DockerVersion string 97 98 // Author is the name of the author that was specified when committing the 99 // image, or as specified through MAINTAINER (deprecated) in the Dockerfile. 100 Author string 101 Config *container.Config 102 103 // Architecture is the hardware CPU architecture that the image runs on. 104 Architecture string 105 106 // Variant is the CPU architecture variant (presently ARM-only). 107 Variant string `json:",omitempty"` 108 109 // OS is the Operating System the image is built to run on. 110 Os string 111 112 // OsVersion is the version of the Operating System the image is built to 113 // run on (especially for Windows). 114 OsVersion string `json:",omitempty"` 115 116 // Size is the total size of the image including all layers it is composed of. 117 Size int64 118 119 // VirtualSize is the total size of the image including all layers it is 120 // composed of. 121 // 122 // Deprecated: this field is omitted in API v1.44, but kept for backward compatibility. Use Size instead. 123 VirtualSize int64 `json:"VirtualSize,omitempty"` 124 125 // GraphDriver holds information about the storage driver used to store the 126 // container's and image's filesystem. 127 GraphDriver GraphDriverData 128 129 // RootFS contains information about the image's RootFS, including the 130 // layer IDs. 131 RootFS RootFS 132 133 // Metadata of the image in the local cache. 134 // 135 // This information is local to the daemon, and not part of the image itself. 136 Metadata image.Metadata 137 } 138 139 // Container contains response of Engine API: 140 // GET "/containers/json" 141 type Container struct { 142 ID string `json:"Id"` 143 Names []string 144 Image string 145 ImageID string 146 Command string 147 Created int64 148 Ports []Port 149 SizeRw int64 `json:",omitempty"` 150 SizeRootFs int64 `json:",omitempty"` 151 Labels map[string]string 152 State string 153 Status string 154 HostConfig struct { 155 NetworkMode string `json:",omitempty"` 156 } 157 NetworkSettings *SummaryNetworkSettings 158 Mounts []MountPoint 159 } 160 161 // CopyConfig contains request body of Engine API: 162 // POST "/containers/"+containerID+"/copy" 163 type CopyConfig struct { 164 Resource string 165 } 166 167 // ContainerPathStat is used to encode the header from 168 // GET "/containers/{name:.*}/archive" 169 // "Name" is the file or directory name. 170 type ContainerPathStat struct { 171 Name string `json:"name"` 172 Size int64 `json:"size"` 173 Mode os.FileMode `json:"mode"` 174 Mtime time.Time `json:"mtime"` 175 LinkTarget string `json:"linkTarget"` 176 } 177 178 // ContainerStats contains response of Engine API: 179 // GET "/stats" 180 type ContainerStats struct { 181 Body io.ReadCloser `json:"body"` 182 OSType string `json:"ostype"` 183 } 184 185 // Ping contains response of Engine API: 186 // GET "/_ping" 187 type Ping struct { 188 APIVersion string 189 OSType string 190 Experimental bool 191 BuilderVersion BuilderVersion 192 193 // SwarmStatus provides information about the current swarm status of the 194 // engine, obtained from the "Swarm" header in the API response. 195 // 196 // It can be a nil struct if the API version does not provide this header 197 // in the ping response, or if an error occurred, in which case the client 198 // should use other ways to get the current swarm status, such as the /swarm 199 // endpoint. 200 SwarmStatus *swarm.Status 201 } 202 203 // ComponentVersion describes the version information for a specific component. 204 type ComponentVersion struct { 205 Name string 206 Version string 207 Details map[string]string `json:",omitempty"` 208 } 209 210 // Version contains response of Engine API: 211 // GET "/version" 212 type Version struct { 213 Platform struct{ Name string } `json:",omitempty"` 214 Components []ComponentVersion `json:",omitempty"` 215 216 // The following fields are deprecated, they relate to the Engine component and are kept for backwards compatibility 217 218 Version string 219 APIVersion string `json:"ApiVersion"` 220 MinAPIVersion string `json:"MinAPIVersion,omitempty"` 221 GitCommit string 222 GoVersion string 223 Os string 224 Arch string 225 KernelVersion string `json:",omitempty"` 226 Experimental bool `json:",omitempty"` 227 BuildTime string `json:",omitempty"` 228 } 229 230 // ExecStartCheck is a temp struct used by execStart 231 // Config fields is part of ExecConfig in runconfig package 232 type ExecStartCheck struct { 233 // ExecStart will first check if it's detached 234 Detach bool 235 // Check if there's a tty 236 Tty bool 237 // Terminal size [height, width], unused if Tty == false 238 ConsoleSize *[2]uint `json:",omitempty"` 239 } 240 241 // HealthcheckResult stores information about a single run of a healthcheck probe 242 type HealthcheckResult struct { 243 Start time.Time // Start is the time this check started 244 End time.Time // End is the time this check ended 245 ExitCode int // ExitCode meanings: 0=healthy, 1=unhealthy, 2=reserved (considered unhealthy), else=error running probe 246 Output string // Output from last check 247 } 248 249 // Health states 250 const ( 251 NoHealthcheck = "none" // Indicates there is no healthcheck 252 Starting = "starting" // Starting indicates that the container is not yet ready 253 Healthy = "healthy" // Healthy indicates that the container is running correctly 254 Unhealthy = "unhealthy" // Unhealthy indicates that the container has a problem 255 ) 256 257 // Health stores information about the container's healthcheck results 258 type Health struct { 259 Status string // Status is one of Starting, Healthy or Unhealthy 260 FailingStreak int // FailingStreak is the number of consecutive failures 261 Log []*HealthcheckResult // Log contains the last few results (oldest first) 262 } 263 264 // ContainerState stores container's running state 265 // it's part of ContainerJSONBase and will return by "inspect" command 266 type ContainerState struct { 267 Status string // String representation of the container state. Can be one of "created", "running", "paused", "restarting", "removing", "exited", or "dead" 268 Running bool 269 Paused bool 270 Restarting bool 271 OOMKilled bool 272 Dead bool 273 Pid int 274 ExitCode int 275 Error string 276 StartedAt string 277 FinishedAt string 278 Health *Health `json:",omitempty"` 279 } 280 281 // ContainerNode stores information about the node that a container 282 // is running on. It's only used by the Docker Swarm standalone API 283 type ContainerNode struct { 284 ID string 285 IPAddress string `json:"IP"` 286 Addr string 287 Name string 288 Cpus int 289 Memory int64 290 Labels map[string]string 291 } 292 293 // ContainerJSONBase contains response of Engine API: 294 // GET "/containers/{name:.*}/json" 295 type ContainerJSONBase struct { 296 ID string `json:"Id"` 297 Created string 298 Path string 299 Args []string 300 State *ContainerState 301 Image string 302 ResolvConfPath string 303 HostnamePath string 304 HostsPath string 305 LogPath string 306 Node *ContainerNode `json:",omitempty"` // Node is only propagated by Docker Swarm standalone API 307 Name string 308 RestartCount int 309 Driver string 310 Platform string 311 MountLabel string 312 ProcessLabel string 313 AppArmorProfile string 314 ExecIDs []string 315 HostConfig *container.HostConfig 316 GraphDriver GraphDriverData 317 SizeRw *int64 `json:",omitempty"` 318 SizeRootFs *int64 `json:",omitempty"` 319 } 320 321 // ContainerJSON is newly used struct along with MountPoint 322 type ContainerJSON struct { 323 *ContainerJSONBase 324 Mounts []MountPoint 325 Config *container.Config 326 NetworkSettings *NetworkSettings 327 } 328 329 // NetworkSettings exposes the network settings in the api 330 type NetworkSettings struct { 331 NetworkSettingsBase 332 DefaultNetworkSettings 333 Networks map[string]*network.EndpointSettings 334 } 335 336 // SummaryNetworkSettings provides a summary of container's networks 337 // in /containers/json 338 type SummaryNetworkSettings struct { 339 Networks map[string]*network.EndpointSettings 340 } 341 342 // NetworkSettingsBase holds networking state for a container when inspecting it. 343 type NetworkSettingsBase struct { 344 Bridge string // Bridge contains the name of the default bridge interface iff it was set through the daemon --bridge flag. 345 SandboxID string // SandboxID uniquely represents a container's network stack 346 SandboxKey string // SandboxKey identifies the sandbox 347 Ports nat.PortMap // Ports is a collection of PortBinding indexed by Port 348 349 // HairpinMode specifies if hairpin NAT should be enabled on the virtual interface 350 // 351 // Deprecated: This field is never set and will be removed in a future release. 352 HairpinMode bool 353 // LinkLocalIPv6Address is an IPv6 unicast address using the link-local prefix 354 // 355 // Deprecated: This field is never set and will be removed in a future release. 356 LinkLocalIPv6Address string 357 // LinkLocalIPv6PrefixLen is the prefix length of an IPv6 unicast address 358 // 359 // Deprecated: This field is never set and will be removed in a future release. 360 LinkLocalIPv6PrefixLen int 361 SecondaryIPAddresses []network.Address // Deprecated: This field is never set and will be removed in a future release. 362 SecondaryIPv6Addresses []network.Address // Deprecated: This field is never set and will be removed in a future release. 363 } 364 365 // DefaultNetworkSettings holds network information 366 // during the 2 release deprecation period. 367 // It will be removed in Docker 1.11. 368 type DefaultNetworkSettings struct { 369 EndpointID string // EndpointID uniquely represents a service endpoint in a Sandbox 370 Gateway string // Gateway holds the gateway address for the network 371 GlobalIPv6Address string // GlobalIPv6Address holds network's global IPv6 address 372 GlobalIPv6PrefixLen int // GlobalIPv6PrefixLen represents mask length of network's global IPv6 address 373 IPAddress string // IPAddress holds the IPv4 address for the network 374 IPPrefixLen int // IPPrefixLen represents mask length of network's IPv4 address 375 IPv6Gateway string // IPv6Gateway holds gateway address specific for IPv6 376 MacAddress string // MacAddress holds the MAC address for the network 377 } 378 379 // MountPoint represents a mount point configuration inside the container. 380 // This is used for reporting the mountpoints in use by a container. 381 type MountPoint struct { 382 // Type is the type of mount, see `Type<foo>` definitions in 383 // github.com/docker/docker/api/types/mount.Type 384 Type mount.Type `json:",omitempty"` 385 386 // Name is the name reference to the underlying data defined by `Source` 387 // e.g., the volume name. 388 Name string `json:",omitempty"` 389 390 // Source is the source location of the mount. 391 // 392 // For volumes, this contains the storage location of the volume (within 393 // `/var/lib/docker/volumes/`). For bind-mounts, and `npipe`, this contains 394 // the source (host) part of the bind-mount. For `tmpfs` mount points, this 395 // field is empty. 396 Source string 397 398 // Destination is the path relative to the container root (`/`) where the 399 // Source is mounted inside the container. 400 Destination string 401 402 // Driver is the volume driver used to create the volume (if it is a volume). 403 Driver string `json:",omitempty"` 404 405 // Mode is a comma separated list of options supplied by the user when 406 // creating the bind/volume mount. 407 // 408 // The default is platform-specific (`"z"` on Linux, empty on Windows). 409 Mode string 410 411 // RW indicates whether the mount is mounted writable (read-write). 412 RW bool 413 414 // Propagation describes how mounts are propagated from the host into the 415 // mount point, and vice-versa. Refer to the Linux kernel documentation 416 // for details: 417 // https://www.kernel.org/doc/Documentation/filesystems/sharedsubtree.txt 418 // 419 // This field is not used on Windows. 420 Propagation mount.Propagation 421 } 422 423 // NetworkResource is the body of the "get network" http response message 424 type NetworkResource struct { 425 Name string // Name is the requested name of the network 426 ID string `json:"Id"` // ID uniquely identifies a network on a single machine 427 Created time.Time // Created is the time the network created 428 Scope string // Scope describes the level at which the network exists (e.g. `swarm` for cluster-wide or `local` for machine level) 429 Driver string // Driver is the Driver name used to create the network (e.g. `bridge`, `overlay`) 430 EnableIPv6 bool // EnableIPv6 represents whether to enable IPv6 431 IPAM network.IPAM // IPAM is the network's IP Address Management 432 Internal bool // Internal represents if the network is used internal only 433 Attachable bool // Attachable represents if the global scope is manually attachable by regular containers from workers in swarm mode. 434 Ingress bool // Ingress indicates the network is providing the routing-mesh for the swarm cluster. 435 ConfigFrom network.ConfigReference // ConfigFrom specifies the source which will provide the configuration for this network. 436 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. 437 Containers map[string]EndpointResource // Containers contains endpoints belonging to the network 438 Options map[string]string // Options holds the network specific options to use for when creating the network 439 Labels map[string]string // Labels holds metadata specific to the network being created 440 Peers []network.PeerInfo `json:",omitempty"` // List of peer nodes for an overlay network 441 Services map[string]network.ServiceInfo `json:",omitempty"` 442 } 443 444 // EndpointResource contains network resources allocated and used for a container in a network 445 type EndpointResource struct { 446 Name string 447 EndpointID string 448 MacAddress string 449 IPv4Address string 450 IPv6Address string 451 } 452 453 // NetworkCreate is the expected body of the "create network" http request message 454 type NetworkCreate struct { 455 // Deprecated: CheckDuplicate is deprecated since API v1.44, but it defaults to true when sent by the client 456 // package to older daemons. 457 CheckDuplicate bool `json:",omitempty"` 458 Driver string 459 Scope string 460 EnableIPv6 bool 461 IPAM *network.IPAM 462 Internal bool 463 Attachable bool 464 Ingress bool 465 ConfigOnly bool 466 ConfigFrom *network.ConfigReference 467 Options map[string]string 468 Labels map[string]string 469 } 470 471 // NetworkCreateRequest is the request message sent to the server for network create call. 472 type NetworkCreateRequest struct { 473 NetworkCreate 474 Name string 475 } 476 477 // NetworkCreateResponse is the response message sent by the server for network create call 478 type NetworkCreateResponse struct { 479 ID string `json:"Id"` 480 Warning string 481 } 482 483 // NetworkConnect represents the data to be used to connect a container to the network 484 type NetworkConnect struct { 485 Container string 486 EndpointConfig *network.EndpointSettings `json:",omitempty"` 487 } 488 489 // NetworkDisconnect represents the data to be used to disconnect a container from the network 490 type NetworkDisconnect struct { 491 Container string 492 Force bool 493 } 494 495 // NetworkInspectOptions holds parameters to inspect network 496 type NetworkInspectOptions struct { 497 Scope string 498 Verbose bool 499 } 500 501 // DiskUsageObject represents an object type used for disk usage query filtering. 502 type DiskUsageObject string 503 504 const ( 505 // ContainerObject represents a container DiskUsageObject. 506 ContainerObject DiskUsageObject = "container" 507 // ImageObject represents an image DiskUsageObject. 508 ImageObject DiskUsageObject = "image" 509 // VolumeObject represents a volume DiskUsageObject. 510 VolumeObject DiskUsageObject = "volume" 511 // BuildCacheObject represents a build-cache DiskUsageObject. 512 BuildCacheObject DiskUsageObject = "build-cache" 513 ) 514 515 // DiskUsageOptions holds parameters for system disk usage query. 516 type DiskUsageOptions struct { 517 // Types specifies what object types to include in the response. If empty, 518 // all object types are returned. 519 Types []DiskUsageObject 520 } 521 522 // DiskUsage contains response of Engine API: 523 // GET "/system/df" 524 type DiskUsage struct { 525 LayersSize int64 526 Images []*image.Summary 527 Containers []*Container 528 Volumes []*volume.Volume 529 BuildCache []*BuildCache 530 BuilderSize int64 `json:",omitempty"` // Deprecated: deprecated in API 1.38, and no longer used since API 1.40. 531 } 532 533 // ContainersPruneReport contains the response for Engine API: 534 // POST "/containers/prune" 535 type ContainersPruneReport struct { 536 ContainersDeleted []string 537 SpaceReclaimed uint64 538 } 539 540 // VolumesPruneReport contains the response for Engine API: 541 // POST "/volumes/prune" 542 type VolumesPruneReport struct { 543 VolumesDeleted []string 544 SpaceReclaimed uint64 545 } 546 547 // ImagesPruneReport contains the response for Engine API: 548 // POST "/images/prune" 549 type ImagesPruneReport struct { 550 ImagesDeleted []image.DeleteResponse 551 SpaceReclaimed uint64 552 } 553 554 // BuildCachePruneReport contains the response for Engine API: 555 // POST "/build/prune" 556 type BuildCachePruneReport struct { 557 CachesDeleted []string 558 SpaceReclaimed uint64 559 } 560 561 // NetworksPruneReport contains the response for Engine API: 562 // POST "/networks/prune" 563 type NetworksPruneReport struct { 564 NetworksDeleted []string 565 } 566 567 // SecretCreateResponse contains the information returned to a client 568 // on the creation of a new secret. 569 type SecretCreateResponse struct { 570 // ID is the id of the created secret. 571 ID string 572 } 573 574 // SecretListOptions holds parameters to list secrets 575 type SecretListOptions struct { 576 Filters filters.Args 577 } 578 579 // ConfigCreateResponse contains the information returned to a client 580 // on the creation of a new config. 581 type ConfigCreateResponse struct { 582 // ID is the id of the created config. 583 ID string 584 } 585 586 // ConfigListOptions holds parameters to list configs 587 type ConfigListOptions struct { 588 Filters filters.Args 589 } 590 591 // PushResult contains the tag, manifest digest, and manifest size from the 592 // push. It's used to signal this information to the trust code in the client 593 // so it can sign the manifest if necessary. 594 type PushResult struct { 595 Tag string 596 Digest string 597 Size int 598 } 599 600 // BuildResult contains the image id of a successful build 601 type BuildResult struct { 602 ID string 603 } 604 605 // BuildCache contains information about a build cache record. 606 type BuildCache struct { 607 // ID is the unique ID of the build cache record. 608 ID string 609 // Parent is the ID of the parent build cache record. 610 // 611 // Deprecated: deprecated in API v1.42 and up, as it was deprecated in BuildKit; use Parents instead. 612 Parent string `json:"Parent,omitempty"` 613 // Parents is the list of parent build cache record IDs. 614 Parents []string `json:" Parents,omitempty"` 615 // Type is the cache record type. 616 Type string 617 // Description is a description of the build-step that produced the build cache. 618 Description string 619 // InUse indicates if the build cache is in use. 620 InUse bool 621 // Shared indicates if the build cache is shared. 622 Shared bool 623 // Size is the amount of disk space used by the build cache (in bytes). 624 Size int64 625 // CreatedAt is the date and time at which the build cache was created. 626 CreatedAt time.Time 627 // LastUsedAt is the date and time at which the build cache was last used. 628 LastUsedAt *time.Time 629 UsageCount int 630 } 631 632 // BuildCachePruneOptions hold parameters to prune the build cache 633 type BuildCachePruneOptions struct { 634 All bool 635 KeepStorage int64 636 Filters filters.Args 637 }