types.go 27 KB

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