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