types.go 28 KB

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