types.go 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804
  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. // Legacy API fields for older API versions.
  273. legacyFields
  274. // Warnings contains a slice of warnings that occurred while collecting
  275. // system information. These warnings are intended to be informational
  276. // messages for the user, and are not intended to be parsed / used for
  277. // other purposes, as they do not have a fixed format.
  278. Warnings []string
  279. }
  280. type legacyFields struct {
  281. ExecutionDriver string `json:",omitempty"` // Deprecated: deprecated since API v1.25, but returned for older versions.
  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. }
  589. // DiskUsageObject represents an object type used for disk usage query filtering.
  590. type DiskUsageObject string
  591. const (
  592. // ContainerObject represents a container DiskUsageObject.
  593. ContainerObject DiskUsageObject = "container"
  594. // ImageObject represents an image DiskUsageObject.
  595. ImageObject DiskUsageObject = "image"
  596. // VolumeObject represents a volume DiskUsageObject.
  597. VolumeObject DiskUsageObject = "volume"
  598. // BuildCacheObject represents a build-cache DiskUsageObject.
  599. BuildCacheObject DiskUsageObject = "build-cache"
  600. )
  601. // DiskUsageOptions holds parameters for system disk usage query.
  602. type DiskUsageOptions struct {
  603. // Types specifies what object types to include in the response. If empty,
  604. // all object types are returned.
  605. Types []DiskUsageObject
  606. }
  607. // DiskUsage contains response of Engine API:
  608. // GET "/system/df"
  609. type DiskUsage struct {
  610. LayersSize int64
  611. Images []*ImageSummary
  612. Containers []*Container
  613. Volumes []*volume.Volume
  614. BuildCache []*BuildCache
  615. BuilderSize int64 `json:",omitempty"` // Deprecated: deprecated in API 1.38, and no longer used since API 1.40.
  616. }
  617. // ContainersPruneReport contains the response for Engine API:
  618. // POST "/containers/prune"
  619. type ContainersPruneReport struct {
  620. ContainersDeleted []string
  621. SpaceReclaimed uint64
  622. }
  623. // VolumesPruneReport contains the response for Engine API:
  624. // POST "/volumes/prune"
  625. type VolumesPruneReport struct {
  626. VolumesDeleted []string
  627. SpaceReclaimed uint64
  628. }
  629. // ImagesPruneReport contains the response for Engine API:
  630. // POST "/images/prune"
  631. type ImagesPruneReport struct {
  632. ImagesDeleted []ImageDeleteResponseItem
  633. SpaceReclaimed uint64
  634. }
  635. // BuildCachePruneReport contains the response for Engine API:
  636. // POST "/build/prune"
  637. type BuildCachePruneReport struct {
  638. CachesDeleted []string
  639. SpaceReclaimed uint64
  640. }
  641. // NetworksPruneReport contains the response for Engine API:
  642. // POST "/networks/prune"
  643. type NetworksPruneReport struct {
  644. NetworksDeleted []string
  645. }
  646. // SecretCreateResponse contains the information returned to a client
  647. // on the creation of a new secret.
  648. type SecretCreateResponse struct {
  649. // ID is the id of the created secret.
  650. ID string
  651. }
  652. // SecretListOptions holds parameters to list secrets
  653. type SecretListOptions struct {
  654. Filters filters.Args
  655. }
  656. // ConfigCreateResponse contains the information returned to a client
  657. // on the creation of a new config.
  658. type ConfigCreateResponse struct {
  659. // ID is the id of the created config.
  660. ID string
  661. }
  662. // ConfigListOptions holds parameters to list configs
  663. type ConfigListOptions struct {
  664. Filters filters.Args
  665. }
  666. // PushResult contains the tag, manifest digest, and manifest size from the
  667. // push. It's used to signal this information to the trust code in the client
  668. // so it can sign the manifest if necessary.
  669. type PushResult struct {
  670. Tag string
  671. Digest string
  672. Size int
  673. }
  674. // BuildResult contains the image id of a successful build
  675. type BuildResult struct {
  676. ID string
  677. }
  678. // BuildCache contains information about a build cache record.
  679. type BuildCache struct {
  680. // ID is the unique ID of the build cache record.
  681. ID string
  682. // Parent is the ID of the parent build cache record.
  683. //
  684. // Deprecated: deprecated in API v1.42 and up, as it was deprecated in BuildKit; use Parents instead.
  685. Parent string `json:"Parent,omitempty"`
  686. // Parents is the list of parent build cache record IDs.
  687. Parents []string `json:" Parents,omitempty"`
  688. // Type is the cache record type.
  689. Type string
  690. // Description is a description of the build-step that produced the build cache.
  691. Description string
  692. // InUse indicates if the build cache is in use.
  693. InUse bool
  694. // Shared indicates if the build cache is shared.
  695. Shared bool
  696. // Size is the amount of disk space used by the build cache (in bytes).
  697. Size int64
  698. // CreatedAt is the date and time at which the build cache was created.
  699. CreatedAt time.Time
  700. // LastUsedAt is the date and time at which the build cache was last used.
  701. LastUsedAt *time.Time
  702. UsageCount int
  703. }
  704. // BuildCachePruneOptions hold parameters to prune the build cache
  705. type BuildCachePruneOptions struct {
  706. All bool
  707. KeepStorage int64
  708. Filters filters.Args
  709. }