types.go 28 KB

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