types.go 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812
  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. for _, s := range strings.Split(opt, ",") {
  310. k, v, ok := strings.Cut(s, "=")
  311. if !ok {
  312. return nil, fmt.Errorf("invalid security option %q", s)
  313. }
  314. if k == "" || v == "" {
  315. return nil, errors.New("invalid empty security option")
  316. }
  317. if k == "name" {
  318. secopt.Name = v
  319. continue
  320. }
  321. secopt.Options = append(secopt.Options, KeyValue{Key: k, Value: v})
  322. }
  323. so = append(so, secopt)
  324. }
  325. return so, nil
  326. }
  327. // PluginsInfo is a temp struct holding Plugins name
  328. // registered with docker daemon. It is used by Info struct
  329. type PluginsInfo struct {
  330. // List of Volume plugins registered
  331. Volume []string
  332. // List of Network plugins registered
  333. Network []string
  334. // List of Authorization plugins registered
  335. Authorization []string
  336. // List of Log plugins registered
  337. Log []string
  338. }
  339. // ExecStartCheck is a temp struct used by execStart
  340. // Config fields is part of ExecConfig in runconfig package
  341. type ExecStartCheck struct {
  342. // ExecStart will first check if it's detached
  343. Detach bool
  344. // Check if there's a tty
  345. Tty bool
  346. // Terminal size [height, width], unused if Tty == false
  347. ConsoleSize *[2]uint `json:",omitempty"`
  348. }
  349. // HealthcheckResult stores information about a single run of a healthcheck probe
  350. type HealthcheckResult struct {
  351. Start time.Time // Start is the time this check started
  352. End time.Time // End is the time this check ended
  353. ExitCode int // ExitCode meanings: 0=healthy, 1=unhealthy, 2=reserved (considered unhealthy), else=error running probe
  354. Output string // Output from last check
  355. }
  356. // Health states
  357. const (
  358. NoHealthcheck = "none" // Indicates there is no healthcheck
  359. Starting = "starting" // Starting indicates that the container is not yet ready
  360. Healthy = "healthy" // Healthy indicates that the container is running correctly
  361. Unhealthy = "unhealthy" // Unhealthy indicates that the container has a problem
  362. )
  363. // Health stores information about the container's healthcheck results
  364. type Health struct {
  365. Status string // Status is one of Starting, Healthy or Unhealthy
  366. FailingStreak int // FailingStreak is the number of consecutive failures
  367. Log []*HealthcheckResult // Log contains the last few results (oldest first)
  368. }
  369. // ContainerState stores container's running state
  370. // it's part of ContainerJSONBase and will return by "inspect" command
  371. type ContainerState struct {
  372. Status string // String representation of the container state. Can be one of "created", "running", "paused", "restarting", "removing", "exited", or "dead"
  373. Running bool
  374. Paused bool
  375. Restarting bool
  376. OOMKilled bool
  377. Dead bool
  378. Pid int
  379. ExitCode int
  380. Error string
  381. StartedAt string
  382. FinishedAt string
  383. Health *Health `json:",omitempty"`
  384. }
  385. // ContainerNode stores information about the node that a container
  386. // is running on. It's only used by the Docker Swarm standalone API
  387. type ContainerNode struct {
  388. ID string
  389. IPAddress string `json:"IP"`
  390. Addr string
  391. Name string
  392. Cpus int
  393. Memory int64
  394. Labels map[string]string
  395. }
  396. // ContainerJSONBase contains response of Engine API:
  397. // GET "/containers/{name:.*}/json"
  398. type ContainerJSONBase struct {
  399. ID string `json:"Id"`
  400. Created string
  401. Path string
  402. Args []string
  403. State *ContainerState
  404. Image string
  405. ResolvConfPath string
  406. HostnamePath string
  407. HostsPath string
  408. LogPath string
  409. Node *ContainerNode `json:",omitempty"` // Node is only propagated by Docker Swarm standalone API
  410. Name string
  411. RestartCount int
  412. Driver string
  413. Platform string
  414. MountLabel string
  415. ProcessLabel string
  416. AppArmorProfile string
  417. ExecIDs []string
  418. HostConfig *container.HostConfig
  419. GraphDriver GraphDriverData
  420. SizeRw *int64 `json:",omitempty"`
  421. SizeRootFs *int64 `json:",omitempty"`
  422. }
  423. // ContainerJSON is newly used struct along with MountPoint
  424. type ContainerJSON struct {
  425. *ContainerJSONBase
  426. Mounts []MountPoint
  427. Config *container.Config
  428. NetworkSettings *NetworkSettings
  429. }
  430. // NetworkSettings exposes the network settings in the api
  431. type NetworkSettings struct {
  432. NetworkSettingsBase
  433. DefaultNetworkSettings
  434. Networks map[string]*network.EndpointSettings
  435. }
  436. // SummaryNetworkSettings provides a summary of container's networks
  437. // in /containers/json
  438. type SummaryNetworkSettings struct {
  439. Networks map[string]*network.EndpointSettings
  440. }
  441. // NetworkSettingsBase holds basic information about networks
  442. type NetworkSettingsBase struct {
  443. Bridge string // Bridge is the Bridge name the network uses(e.g. `docker0`)
  444. SandboxID string // SandboxID uniquely represents a container's network stack
  445. HairpinMode bool // HairpinMode specifies if hairpin NAT should be enabled on the virtual interface
  446. LinkLocalIPv6Address string // LinkLocalIPv6Address is an IPv6 unicast address using the link-local prefix
  447. LinkLocalIPv6PrefixLen int // LinkLocalIPv6PrefixLen is the prefix length of an IPv6 unicast address
  448. Ports nat.PortMap // Ports is a collection of PortBinding indexed by Port
  449. SandboxKey string // SandboxKey identifies the sandbox
  450. SecondaryIPAddresses []network.Address
  451. SecondaryIPv6Addresses []network.Address
  452. }
  453. // DefaultNetworkSettings holds network information
  454. // during the 2 release deprecation period.
  455. // It will be removed in Docker 1.11.
  456. type DefaultNetworkSettings struct {
  457. EndpointID string // EndpointID uniquely represents a service endpoint in a Sandbox
  458. Gateway string // Gateway holds the gateway address for the network
  459. GlobalIPv6Address string // GlobalIPv6Address holds network's global IPv6 address
  460. GlobalIPv6PrefixLen int // GlobalIPv6PrefixLen represents mask length of network's global IPv6 address
  461. IPAddress string // IPAddress holds the IPv4 address for the network
  462. IPPrefixLen int // IPPrefixLen represents mask length of network's IPv4 address
  463. IPv6Gateway string // IPv6Gateway holds gateway address specific for IPv6
  464. MacAddress string // MacAddress holds the MAC address for the network
  465. }
  466. // MountPoint represents a mount point configuration inside the container.
  467. // This is used for reporting the mountpoints in use by a container.
  468. type MountPoint struct {
  469. // Type is the type of mount, see `Type<foo>` definitions in
  470. // github.com/docker/docker/api/types/mount.Type
  471. Type mount.Type `json:",omitempty"`
  472. // Name is the name reference to the underlying data defined by `Source`
  473. // e.g., the volume name.
  474. Name string `json:",omitempty"`
  475. // Source is the source location of the mount.
  476. //
  477. // For volumes, this contains the storage location of the volume (within
  478. // `/var/lib/docker/volumes/`). For bind-mounts, and `npipe`, this contains
  479. // the source (host) part of the bind-mount. For `tmpfs` mount points, this
  480. // field is empty.
  481. Source string
  482. // Destination is the path relative to the container root (`/`) where the
  483. // Source is mounted inside the container.
  484. Destination string
  485. // Driver is the volume driver used to create the volume (if it is a volume).
  486. Driver string `json:",omitempty"`
  487. // Mode is a comma separated list of options supplied by the user when
  488. // creating the bind/volume mount.
  489. //
  490. // The default is platform-specific (`"z"` on Linux, empty on Windows).
  491. Mode string
  492. // RW indicates whether the mount is mounted writable (read-write).
  493. RW bool
  494. // Propagation describes how mounts are propagated from the host into the
  495. // mount point, and vice-versa. Refer to the Linux kernel documentation
  496. // for details:
  497. // https://www.kernel.org/doc/Documentation/filesystems/sharedsubtree.txt
  498. //
  499. // This field is not used on Windows.
  500. Propagation mount.Propagation
  501. }
  502. // NetworkResource is the body of the "get network" http response message
  503. type NetworkResource struct {
  504. Name string // Name is the requested name of the network
  505. ID string `json:"Id"` // ID uniquely identifies a network on a single machine
  506. Created time.Time // Created is the time the network created
  507. Scope string // Scope describes the level at which the network exists (e.g. `swarm` for cluster-wide or `local` for machine level)
  508. Driver string // Driver is the Driver name used to create the network (e.g. `bridge`, `overlay`)
  509. EnableIPv6 bool // EnableIPv6 represents whether to enable IPv6
  510. IPAM network.IPAM // IPAM is the network's IP Address Management
  511. Internal bool // Internal represents if the network is used internal only
  512. Attachable bool // Attachable represents if the global scope is manually attachable by regular containers from workers in swarm mode.
  513. Ingress bool // Ingress indicates the network is providing the routing-mesh for the swarm cluster.
  514. ConfigFrom network.ConfigReference // ConfigFrom specifies the source which will provide the configuration for this network.
  515. 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.
  516. Containers map[string]EndpointResource // Containers contains endpoints belonging to the network
  517. Options map[string]string // Options holds the network specific options to use for when creating the network
  518. Labels map[string]string // Labels holds metadata specific to the network being created
  519. Peers []network.PeerInfo `json:",omitempty"` // List of peer nodes for an overlay network
  520. Services map[string]network.ServiceInfo `json:",omitempty"`
  521. }
  522. // EndpointResource contains network resources allocated and used for a container in a network
  523. type EndpointResource struct {
  524. Name string
  525. EndpointID string
  526. MacAddress string
  527. IPv4Address string
  528. IPv6Address string
  529. }
  530. // NetworkCreate is the expected body of the "create network" http request message
  531. type NetworkCreate struct {
  532. // Check for networks with duplicate names.
  533. // Network is primarily keyed based on a random ID and not on the name.
  534. // Network name is strictly a user-friendly alias to the network
  535. // which is uniquely identified using ID.
  536. // And there is no guaranteed way to check for duplicates.
  537. // Option CheckDuplicate is there to provide a best effort checking of any networks
  538. // which has the same name but it is not guaranteed to catch all name collisions.
  539. CheckDuplicate bool
  540. Driver string
  541. Scope string
  542. EnableIPv6 bool
  543. IPAM *network.IPAM
  544. Internal bool
  545. Attachable bool
  546. Ingress bool
  547. ConfigOnly bool
  548. ConfigFrom *network.ConfigReference
  549. Options map[string]string
  550. Labels map[string]string
  551. }
  552. // NetworkCreateRequest is the request message sent to the server for network create call.
  553. type NetworkCreateRequest struct {
  554. NetworkCreate
  555. Name string
  556. }
  557. // NetworkCreateResponse is the response message sent by the server for network create call
  558. type NetworkCreateResponse struct {
  559. ID string `json:"Id"`
  560. Warning string
  561. }
  562. // NetworkConnect represents the data to be used to connect a container to the network
  563. type NetworkConnect struct {
  564. Container string
  565. EndpointConfig *network.EndpointSettings `json:",omitempty"`
  566. }
  567. // NetworkDisconnect represents the data to be used to disconnect a container from the network
  568. type NetworkDisconnect struct {
  569. Container string
  570. Force bool
  571. }
  572. // NetworkInspectOptions holds parameters to inspect network
  573. type NetworkInspectOptions struct {
  574. Scope string
  575. Verbose bool
  576. }
  577. // Checkpoint represents the details of a checkpoint
  578. type Checkpoint struct {
  579. Name string // Name is the name of the checkpoint
  580. }
  581. // Runtime describes an OCI runtime
  582. type Runtime struct {
  583. // "Legacy" runtime configuration for runc-compatible runtimes.
  584. Path string `json:"path,omitempty"`
  585. Args []string `json:"runtimeArgs,omitempty"`
  586. // Shimv2 runtime configuration. Mutually exclusive with the legacy config above.
  587. Type string `json:"runtimeType,omitempty"`
  588. Options map[string]interface{} `json:"options,omitempty"`
  589. // This is exposed here only for internal use
  590. ShimConfig *ShimConfig `json:"-"`
  591. }
  592. // ShimConfig is used by runtime to configure containerd shims
  593. type ShimConfig struct {
  594. Binary string
  595. Opts interface{}
  596. }
  597. // DiskUsageObject represents an object type used for disk usage query filtering.
  598. type DiskUsageObject string
  599. const (
  600. // ContainerObject represents a container DiskUsageObject.
  601. ContainerObject DiskUsageObject = "container"
  602. // ImageObject represents an image DiskUsageObject.
  603. ImageObject DiskUsageObject = "image"
  604. // VolumeObject represents a volume DiskUsageObject.
  605. VolumeObject DiskUsageObject = "volume"
  606. // BuildCacheObject represents a build-cache DiskUsageObject.
  607. BuildCacheObject DiskUsageObject = "build-cache"
  608. )
  609. // DiskUsageOptions holds parameters for system disk usage query.
  610. type DiskUsageOptions struct {
  611. // Types specifies what object types to include in the response. If empty,
  612. // all object types are returned.
  613. Types []DiskUsageObject
  614. }
  615. // DiskUsage contains response of Engine API:
  616. // GET "/system/df"
  617. type DiskUsage struct {
  618. LayersSize int64
  619. Images []*ImageSummary
  620. Containers []*Container
  621. Volumes []*volume.Volume
  622. BuildCache []*BuildCache
  623. BuilderSize int64 `json:",omitempty"` // Deprecated: deprecated in API 1.38, and no longer used since API 1.40.
  624. }
  625. // ContainersPruneReport contains the response for Engine API:
  626. // POST "/containers/prune"
  627. type ContainersPruneReport struct {
  628. ContainersDeleted []string
  629. SpaceReclaimed uint64
  630. }
  631. // VolumesPruneReport contains the response for Engine API:
  632. // POST "/volumes/prune"
  633. type VolumesPruneReport struct {
  634. VolumesDeleted []string
  635. SpaceReclaimed uint64
  636. }
  637. // ImagesPruneReport contains the response for Engine API:
  638. // POST "/images/prune"
  639. type ImagesPruneReport struct {
  640. ImagesDeleted []ImageDeleteResponseItem
  641. SpaceReclaimed uint64
  642. }
  643. // BuildCachePruneReport contains the response for Engine API:
  644. // POST "/build/prune"
  645. type BuildCachePruneReport struct {
  646. CachesDeleted []string
  647. SpaceReclaimed uint64
  648. }
  649. // NetworksPruneReport contains the response for Engine API:
  650. // POST "/networks/prune"
  651. type NetworksPruneReport struct {
  652. NetworksDeleted []string
  653. }
  654. // SecretCreateResponse contains the information returned to a client
  655. // on the creation of a new secret.
  656. type SecretCreateResponse struct {
  657. // ID is the id of the created secret.
  658. ID string
  659. }
  660. // SecretListOptions holds parameters to list secrets
  661. type SecretListOptions struct {
  662. Filters filters.Args
  663. }
  664. // ConfigCreateResponse contains the information returned to a client
  665. // on the creation of a new config.
  666. type ConfigCreateResponse struct {
  667. // ID is the id of the created config.
  668. ID string
  669. }
  670. // ConfigListOptions holds parameters to list configs
  671. type ConfigListOptions struct {
  672. Filters filters.Args
  673. }
  674. // PushResult contains the tag, manifest digest, and manifest size from the
  675. // push. It's used to signal this information to the trust code in the client
  676. // so it can sign the manifest if necessary.
  677. type PushResult struct {
  678. Tag string
  679. Digest string
  680. Size int
  681. }
  682. // BuildResult contains the image id of a successful build
  683. type BuildResult struct {
  684. ID string
  685. }
  686. // BuildCache contains information about a build cache record.
  687. type BuildCache struct {
  688. // ID is the unique ID of the build cache record.
  689. ID string
  690. // Parent is the ID of the parent build cache record.
  691. //
  692. // Deprecated: deprecated in API v1.42 and up, as it was deprecated in BuildKit; use Parents instead.
  693. Parent string `json:"Parent,omitempty"`
  694. // Parents is the list of parent build cache record IDs.
  695. Parents []string `json:" Parents,omitempty"`
  696. // Type is the cache record type.
  697. Type string
  698. // Description is a description of the build-step that produced the build cache.
  699. Description string
  700. // InUse indicates if the build cache is in use.
  701. InUse bool
  702. // Shared indicates if the build cache is shared.
  703. Shared bool
  704. // Size is the amount of disk space used by the build cache (in bytes).
  705. Size int64
  706. // CreatedAt is the date and time at which the build cache was created.
  707. CreatedAt time.Time
  708. // LastUsedAt is the date and time at which the build cache was last used.
  709. LastUsedAt *time.Time
  710. UsageCount int
  711. }
  712. // BuildCachePruneOptions hold parameters to prune the build cache
  713. type BuildCachePruneOptions struct {
  714. All bool
  715. KeepStorage int64
  716. Filters filters.Args
  717. }