github.com/kim0/docker@v0.6.2-0.20161130212042-4addda3f07e7/api/types/types.go (about) 1 package 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/mount" 10 "github.com/docker/docker/api/types/network" 11 "github.com/docker/docker/api/types/registry" 12 "github.com/docker/docker/api/types/swarm" 13 "github.com/docker/go-connections/nat" 14 ) 15 16 // ContainerCreateResponse contains the information returned to a client on the 17 // creation of a new container. 18 type ContainerCreateResponse struct { 19 // ID is the ID of the created container. 20 ID string `json:"Id"` 21 22 // Warnings are any warnings encountered during the creation of the container. 23 Warnings []string `json:"Warnings"` 24 } 25 26 // ContainerExecCreateResponse contains response of Remote API: 27 // POST "/containers/{name:.*}/exec" 28 type ContainerExecCreateResponse struct { 29 // ID is the exec ID. 30 ID string `json:"Id"` 31 } 32 33 // ContainerUpdateResponse contains response of Remote API: 34 // POST "/containers/{name:.*}/update" 35 type ContainerUpdateResponse struct { 36 // Warnings are any warnings encountered during the updating of the container. 37 Warnings []string `json:"Warnings"` 38 } 39 40 // AuthResponse contains response of Remote API: 41 // POST "/auth" 42 type AuthResponse struct { 43 // Status is the authentication status 44 Status string `json:"Status"` 45 46 // IdentityToken is an opaque token used for authenticating 47 // a user after a successful login. 48 IdentityToken string `json:"IdentityToken,omitempty"` 49 } 50 51 // ContainerWaitResponse contains response of Remote API: 52 // POST "/containers/"+containerID+"/wait" 53 type ContainerWaitResponse struct { 54 // StatusCode is the status code of the wait job 55 StatusCode int `json:"StatusCode"` 56 } 57 58 // ContainerCommitResponse contains response of Remote API: 59 // POST "/commit?container="+containerID 60 type ContainerCommitResponse struct { 61 ID string `json:"Id"` 62 } 63 64 // ContainerChange contains response of Remote API: 65 // GET "/containers/{name:.*}/changes" 66 type ContainerChange struct { 67 Kind int 68 Path string 69 } 70 71 // ImageHistory contains response of Remote API: 72 // GET "/images/{name:.*}/history" 73 type ImageHistory struct { 74 ID string `json:"Id"` 75 Created int64 76 CreatedBy string 77 Tags []string 78 Size int64 79 Comment string 80 } 81 82 // ImageDelete contains response of Remote API: 83 // DELETE "/images/{name:.*}" 84 type ImageDelete struct { 85 Untagged string `json:",omitempty"` 86 Deleted string `json:",omitempty"` 87 } 88 89 // GraphDriverData returns Image's graph driver config info 90 // when calling inspect command 91 type GraphDriverData struct { 92 Name string 93 Data map[string]string 94 } 95 96 // RootFS returns Image's RootFS description including the layer IDs. 97 type RootFS struct { 98 Type string 99 Layers []string `json:",omitempty"` 100 BaseLayer string `json:",omitempty"` 101 } 102 103 // ImageInspect contains response of Remote API: 104 // GET "/images/{name:.*}/json" 105 type ImageInspect struct { 106 ID string `json:"Id"` 107 RepoTags []string 108 RepoDigests []string 109 Parent string 110 Comment string 111 Created string 112 Container string 113 ContainerConfig *container.Config 114 DockerVersion string 115 Author string 116 Config *container.Config 117 Architecture string 118 Os string 119 OsVersion string `json:",omitempty"` 120 Size int64 121 VirtualSize int64 122 GraphDriver GraphDriverData 123 RootFS RootFS 124 } 125 126 // Container contains response of Remote API: 127 // GET "/containers/json" 128 type Container struct { 129 ID string `json:"Id"` 130 Names []string 131 Image string 132 ImageID string 133 Command string 134 Created int64 135 Ports []Port 136 SizeRw int64 `json:",omitempty"` 137 SizeRootFs int64 `json:",omitempty"` 138 Labels map[string]string 139 State string 140 Status string 141 HostConfig struct { 142 NetworkMode string `json:",omitempty"` 143 } 144 NetworkSettings *SummaryNetworkSettings 145 Mounts []MountPoint 146 } 147 148 // CopyConfig contains request body of Remote API: 149 // POST "/containers/"+containerID+"/copy" 150 type CopyConfig struct { 151 Resource string 152 } 153 154 // ContainerPathStat is used to encode the header from 155 // GET "/containers/{name:.*}/archive" 156 // "Name" is the file or directory name. 157 type ContainerPathStat struct { 158 Name string `json:"name"` 159 Size int64 `json:"size"` 160 Mode os.FileMode `json:"mode"` 161 Mtime time.Time `json:"mtime"` 162 LinkTarget string `json:"linkTarget"` 163 } 164 165 // ContainerStats contains response of Remote API: 166 // GET "/stats" 167 type ContainerStats struct { 168 Body io.ReadCloser `json:"body"` 169 OSType string `json:"ostype"` 170 } 171 172 // ContainerProcessList contains response of Remote API: 173 // GET "/containers/{name:.*}/top" 174 type ContainerProcessList struct { 175 Processes [][]string 176 Titles []string 177 } 178 179 // Version contains response of Remote API: 180 // GET "/version" 181 type Version struct { 182 Version string 183 APIVersion string `json:"ApiVersion"` 184 GitCommit string 185 GoVersion string 186 Os string 187 Arch string 188 KernelVersion string `json:",omitempty"` 189 Experimental bool `json:",omitempty"` 190 BuildTime string `json:",omitempty"` 191 } 192 193 // Info contains response of Remote API: 194 // GET "/info" 195 type Info struct { 196 ID string 197 Containers int 198 ContainersRunning int 199 ContainersPaused int 200 ContainersStopped int 201 Images int 202 Driver string 203 DriverStatus [][2]string 204 SystemStatus [][2]string 205 Plugins PluginsInfo 206 MemoryLimit bool 207 SwapLimit bool 208 KernelMemory bool 209 CPUCfsPeriod bool `json:"CpuCfsPeriod"` 210 CPUCfsQuota bool `json:"CpuCfsQuota"` 211 CPUShares bool 212 CPUSet bool 213 IPv4Forwarding bool 214 BridgeNfIptables bool 215 BridgeNfIP6tables bool `json:"BridgeNfIp6tables"` 216 Debug bool 217 NFd int 218 OomKillDisable bool 219 NGoroutines int 220 SystemTime string 221 LoggingDriver string 222 CgroupDriver string 223 NEventsListener int 224 KernelVersion string 225 OperatingSystem string 226 OSType string 227 Architecture string 228 IndexServerAddress string 229 RegistryConfig *registry.ServiceConfig 230 NCPU int 231 MemTotal int64 232 DockerRootDir string 233 HTTPProxy string `json:"HttpProxy"` 234 HTTPSProxy string `json:"HttpsProxy"` 235 NoProxy string 236 Name string 237 Labels []string 238 ExperimentalBuild bool 239 ServerVersion string 240 ClusterStore string 241 ClusterAdvertise string 242 SecurityOptions []string 243 Runtimes map[string]Runtime 244 DefaultRuntime string 245 Swarm swarm.Info 246 // LiveRestoreEnabled determines whether containers should be kept 247 // running when the daemon is shutdown or upon daemon start if 248 // running containers are detected 249 LiveRestoreEnabled bool 250 Isolation container.Isolation 251 } 252 253 // PluginsInfo is a temp struct holding Plugins name 254 // registered with docker daemon. It is used by Info struct 255 type PluginsInfo struct { 256 // List of Volume plugins registered 257 Volume []string 258 // List of Network plugins registered 259 Network []string 260 // List of Authorization plugins registered 261 Authorization []string 262 } 263 264 // ExecStartCheck is a temp struct used by execStart 265 // Config fields is part of ExecConfig in runconfig package 266 type ExecStartCheck struct { 267 // ExecStart will first check if it's detached 268 Detach bool 269 // Check if there's a tty 270 Tty bool 271 } 272 273 // HealthcheckResult stores information about a single run of a healthcheck probe 274 type HealthcheckResult struct { 275 Start time.Time // Start is the time this check started 276 End time.Time // End is the time this check ended 277 ExitCode int // ExitCode meanings: 0=healthy, 1=unhealthy, 2=reserved (considered unhealthy), else=error running probe 278 Output string // Output from last check 279 } 280 281 // Health states 282 const ( 283 NoHealthcheck = "none" // Indicates there is no healthcheck 284 Starting = "starting" // Starting indicates that the container is not yet ready 285 Healthy = "healthy" // Healthy indicates that the container is running correctly 286 Unhealthy = "unhealthy" // Unhealthy indicates that the container has a problem 287 ) 288 289 // Health stores information about the container's healthcheck results 290 type Health struct { 291 Status string // Status is one of Starting, Healthy or Unhealthy 292 FailingStreak int // FailingStreak is the number of consecutive failures 293 Log []*HealthcheckResult // Log contains the last few results (oldest first) 294 } 295 296 // ContainerState stores container's running state 297 // it's part of ContainerJSONBase and will return by "inspect" command 298 type ContainerState struct { 299 Status string 300 Running bool 301 Paused bool 302 Restarting bool 303 OOMKilled bool 304 Dead bool 305 Pid int 306 ExitCode int 307 Error string 308 StartedAt string 309 FinishedAt string 310 Health *Health `json:",omitempty"` 311 } 312 313 // ContainerNode stores information about the node that a container 314 // is running on. It's only available in Docker Swarm 315 type ContainerNode struct { 316 ID string 317 IPAddress string `json:"IP"` 318 Addr string 319 Name string 320 Cpus int 321 Memory int64 322 Labels map[string]string 323 } 324 325 // ContainerJSONBase contains response of Remote API: 326 // GET "/containers/{name:.*}/json" 327 type ContainerJSONBase struct { 328 ID string `json:"Id"` 329 Created string 330 Path string 331 Args []string 332 State *ContainerState 333 Image string 334 ResolvConfPath string 335 HostnamePath string 336 HostsPath string 337 LogPath string 338 Node *ContainerNode `json:",omitempty"` 339 Name string 340 RestartCount int 341 Driver string 342 MountLabel string 343 ProcessLabel string 344 AppArmorProfile string 345 ExecIDs []string 346 HostConfig *container.HostConfig 347 GraphDriver GraphDriverData 348 SizeRw *int64 `json:",omitempty"` 349 SizeRootFs *int64 `json:",omitempty"` 350 } 351 352 // ContainerJSON is newly used struct along with MountPoint 353 type ContainerJSON struct { 354 *ContainerJSONBase 355 Mounts []MountPoint 356 Config *container.Config 357 NetworkSettings *NetworkSettings 358 } 359 360 // NetworkSettings exposes the network settings in the api 361 type NetworkSettings struct { 362 NetworkSettingsBase 363 DefaultNetworkSettings 364 Networks map[string]*network.EndpointSettings 365 } 366 367 // SummaryNetworkSettings provides a summary of container's networks 368 // in /containers/json 369 type SummaryNetworkSettings struct { 370 Networks map[string]*network.EndpointSettings 371 } 372 373 // NetworkSettingsBase holds basic information about networks 374 type NetworkSettingsBase struct { 375 Bridge string // Bridge is the Bridge name the network uses(e.g. `docker0`) 376 SandboxID string // SandboxID uniquely represents a container's network stack 377 HairpinMode bool // HairpinMode specifies if hairpin NAT should be enabled on the virtual interface 378 LinkLocalIPv6Address string // LinkLocalIPv6Address is an IPv6 unicast address using the link-local prefix 379 LinkLocalIPv6PrefixLen int // LinkLocalIPv6PrefixLen is the prefix length of an IPv6 unicast address 380 Ports nat.PortMap // Ports is a collection of PortBinding indexed by Port 381 SandboxKey string // SandboxKey identifies the sandbox 382 SecondaryIPAddresses []network.Address 383 SecondaryIPv6Addresses []network.Address 384 } 385 386 // DefaultNetworkSettings holds network information 387 // during the 2 release deprecation period. 388 // It will be removed in Docker 1.11. 389 type DefaultNetworkSettings struct { 390 EndpointID string // EndpointID uniquely represents a service endpoint in a Sandbox 391 Gateway string // Gateway holds the gateway address for the network 392 GlobalIPv6Address string // GlobalIPv6Address holds network's global IPv6 address 393 GlobalIPv6PrefixLen int // GlobalIPv6PrefixLen represents mask length of network's global IPv6 address 394 IPAddress string // IPAddress holds the IPv4 address for the network 395 IPPrefixLen int // IPPrefixLen represents mask length of network's IPv4 address 396 IPv6Gateway string // IPv6Gateway holds gateway address specific for IPv6 397 MacAddress string // MacAddress holds the MAC address for the network 398 } 399 400 // MountPoint represents a mount point configuration inside the container. 401 // This is used for reporting the mountpoints in use by a container. 402 type MountPoint struct { 403 Type mount.Type `json:",omitempty"` 404 Name string `json:",omitempty"` 405 Source string 406 Destination string 407 Driver string `json:",omitempty"` 408 Mode string 409 RW bool 410 Propagation mount.Propagation 411 } 412 413 // VolumesListResponse contains the response for the remote API: 414 // GET "/volumes" 415 type VolumesListResponse struct { 416 Volumes []*Volume // Volumes is the list of volumes being returned 417 Warnings []string // Warnings is a list of warnings that occurred when getting the list from the volume drivers 418 } 419 420 // VolumeCreateRequest contains the request for the remote API: 421 // POST "/volumes/create" 422 type VolumeCreateRequest struct { 423 Name string // Name is the requested name of the volume 424 Driver string // Driver is the name of the driver that should be used to create the volume 425 DriverOpts map[string]string // DriverOpts holds the driver specific options to use for when creating the volume. 426 Labels map[string]string // Labels holds metadata specific to the volume being created. 427 } 428 429 // NetworkResource is the body of the "get network" http response message 430 type NetworkResource struct { 431 Name string // Name is the requested name of the network 432 ID string `json:"Id"` // ID uniquely identifies a network on a single machine 433 Created time.Time // Created is the time the network created 434 Scope string // Scope describes the level at which the network exists (e.g. `global` for cluster-wide or `local` for machine level) 435 Driver string // Driver is the Driver name used to create the network (e.g. `bridge`, `overlay`) 436 EnableIPv6 bool // EnableIPv6 represents whether to enable IPv6 437 IPAM network.IPAM // IPAM is the network's IP Address Management 438 Internal bool // Internal represents if the network is used internal only 439 Attachable bool // Attachable represents if the global scope is manually attachable by regular containers from workers in swarm mode. 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 } 444 445 // EndpointResource contains network resources allocated and used for a container in a network 446 type EndpointResource struct { 447 Name string 448 EndpointID string 449 MacAddress string 450 IPv4Address string 451 IPv6Address string 452 } 453 454 // NetworkCreate is the expected body of the "create network" http request message 455 type NetworkCreate struct { 456 CheckDuplicate bool 457 Driver string 458 EnableIPv6 bool 459 IPAM *network.IPAM 460 Internal bool 461 Attachable bool 462 Options map[string]string 463 Labels map[string]string 464 } 465 466 // NetworkCreateRequest is the request message sent to the server for network create call. 467 type NetworkCreateRequest struct { 468 NetworkCreate 469 Name string 470 } 471 472 // NetworkCreateResponse is the response message sent by the server for network create call 473 type NetworkCreateResponse struct { 474 ID string `json:"Id"` 475 Warning string 476 } 477 478 // NetworkConnect represents the data to be used to connect a container to the network 479 type NetworkConnect struct { 480 Container string 481 EndpointConfig *network.EndpointSettings `json:",omitempty"` 482 } 483 484 // NetworkDisconnect represents the data to be used to disconnect a container from the network 485 type NetworkDisconnect struct { 486 Container string 487 Force bool 488 } 489 490 // Checkpoint represents the details of a checkpoint 491 type Checkpoint struct { 492 Name string // Name is the name of the checkpoint 493 } 494 495 // Runtime describes an OCI runtime 496 type Runtime struct { 497 Path string `json:"path"` 498 Args []string `json:"runtimeArgs,omitempty"` 499 } 500 501 // DiskUsage contains response of Remote API: 502 // GET "/system/df" 503 type DiskUsage struct { 504 LayersSize int64 505 Images []*ImageSummary 506 Containers []*Container 507 Volumes []*Volume 508 } 509 510 // ImagesPruneConfig contains the configuration for Remote API: 511 // POST "/images/prune" 512 type ImagesPruneConfig struct { 513 DanglingOnly bool 514 } 515 516 // ContainersPruneConfig contains the configuration for Remote API: 517 // POST "/images/prune" 518 type ContainersPruneConfig struct { 519 } 520 521 // VolumesPruneConfig contains the configuration for Remote API: 522 // POST "/images/prune" 523 type VolumesPruneConfig struct { 524 } 525 526 // NetworksPruneConfig contains the configuration for Remote API: 527 // POST "/networks/prune" 528 type NetworksPruneConfig struct { 529 } 530 531 // ContainersPruneReport contains the response for Remote API: 532 // POST "/containers/prune" 533 type ContainersPruneReport struct { 534 ContainersDeleted []string 535 SpaceReclaimed uint64 536 } 537 538 // VolumesPruneReport contains the response for Remote API: 539 // POST "/volumes/prune" 540 type VolumesPruneReport struct { 541 VolumesDeleted []string 542 SpaceReclaimed uint64 543 } 544 545 // ImagesPruneReport contains the response for Remote API: 546 // POST "/images/prune" 547 type ImagesPruneReport struct { 548 ImagesDeleted []ImageDelete 549 SpaceReclaimed uint64 550 } 551 552 // NetworksPruneReport contains the response for Remote API: 553 // POST "/networks/prune" 554 type NetworksPruneReport struct { 555 NetworksDeleted []string 556 }