types.go 27 KB

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