types.go 28 KB

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